CSS Regions allow content to flow across multiple areas called regions.
With CSS Regions you can separate the content from the layout therefore you can create responsive content very easily.
Let's see how.
flow-into and flow-from
The flow-into CSS property can be used to prevent some content from displaying normally, but rather have its display redirected to a named flow:
#source { -webkit-flow-into: main-thread; flow-into: main-thread; }
Then you can specify the layout, and tell it where to get its content from using theflow-from CSS property:
.region { -webkit-flow-from: main-thread; flow-from: main-thread; }
Note that all of the content in the element with ID source will actually get rendered into the layout specified by all of the elements of class region.
Example
Let’s take a look at an example.
First of all, make sure you are using this with either a Webkit nightly, Chrome Canary or an up-to-date Chrome browser. Then, enable CSS regions by navigating to chrome://flags and clicking on “Enable” under Enable experimental Webkit features.
HTML
<div class="region"></div> <img src="https://media.ma-no.org/imgr/1000-600/admin-php.jpg"> <div class="region"></div> <div class="region"></div> <div class="region"></div> <div class="region"></div> <div class="region"></div> <div class="region"></div> <div id="source"> Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which oasted parts of sentences fly into your mouth. </div>
CSS
#source { -webkit-flow-into: main-thread; float-into: main-thread; } img { width: 200px; float: left; margin: 10px 5px; } .region { width: 150px; height: 150px; float: left; margin: 10px 5px; -webkit-flow-from: main-thread; flow-from: main-thread; }
Basically, we have a div: ID issource. That div contains all of the text to be displayed, but, thanks to the CSS
#source {-webkit-flow-into: main-thread;float-into: main-thread; }
the text gets redirected into the named flow called main-thread and doesn’t display in its original div.
We also have other divs, all of class region. In the CSS we have:
.region { width: 150px; height: 150px; float: left; margin: 10px 5px; -webkit-flow-from: main-thread; flow-from: main-thread; }
Those regions will get their content from the main-thread named flow.
The divs will automatically re-layout as you adjust the width of the window.
Finally,we stuck an image in the middle to show that the regions can be easily interspersed with other content.
You can find out more about CSS Regions here.
This article was inspired by http://blattchat.com/2013/08/16/responsive-text-using-css-regions/
Janeth Kent
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.
Related Posts
Alternative tools for graphic design
There are many people today who only use the following for design purposes Canva as it is a really popular software and website and there is no denying that it…
Android Hidden Codes: unveiling custom dialer codes and their functionality
In the world of Android smartphones, there exist numerous hidden codes that can unlock a treasure trove of functionalities and features. These codes, known as custom dialer codes, provide access…
Let's create a Color Picker from scratch with HTML5 Canvas, Javascript and CSS3
HTML5 Canvas is a technology that allows developers to generate real-time graphics and animations using JavaScript. It provides a blank canvas on which graphical elements, such as lines, shapes, images…
How to make your own custom cursor for your website
When I started browsing different and original websites to learn from them, one of the first things that caught my attention was that some of them had their own cursors,…
8 benefits of having a website for your business
At this moment, the Internet is a phenomenon that is sweeping the world. It has been able to interconnect millions of users all over the planet. People have made the…
Open source web design tools alternatives
There are many prototyping tools, user interface design tools or vector graphics applications. But most of them are paid or closed source. So here I will show you several open…
How to create a .onion domain for your website
The dark web, a hidden network accessed through the Tor browser, offers enhanced privacy and anonymity for websites. To establish a presence on the dark web, you can create a…
Secret iPhone codes to unlock hidden features
We love that our devices have hidden features. It's fun to learn something new about the technology we use every day, to discover those little features that aren't advertised by the…
How to access webcam and grab an image using HTML5 and Javascript
We often use webcams to broadcast video in real time via our computer. This broadcast can be viewed, saved and even shared via the Internet. As a rule, we need…
How to Send Email from an HTML Contact Form
In today’s article we will write about how to make a working form that upon hitting that submit button will be functional and send the email (to you as a…
Use the SRCSET attribute to improve your SEO
There is a new standard HTML attribute that can be used in conjunction with IMG called SRCSET. It is new and important as it allows webmasters to display different images…
How to multiply matrices in JavaScript
It may seem strange to want to know how to multiply matrices in JavaScript. But we will see some examples where it is useful to know how to perform this…