CSS Exclusions and Grid Layout

There is a tiny little specification that originally started life linked to the Shapes specification, the original Exclusions and Shapes draft defined both shape-inside and shape-outside along with properties wrap-flow and wrap-through. These propertie…


This content originally appeared on this is rachelandrew.co.uk and was authored by this is rachelandrew.co.uk

There is a tiny little specification that originally started life linked to the Shapes specification, the original Exclusions and Shapes draft defined both shape-inside and shape-outside along with properties wrap-flow and wrap-through. These properties were to create Exclusions.

The Exclusions and Shapes specification was split. The shape-outside property went into Level 1 of CSS Shapes and is now implemented in some browsers. The shape-inside property, was moved to Level 2 of that module. The properties that create exclusions were moved to their own specification. At the current time the only browsers with support for exclusions are Internet Explorer 10, 11 and Edge.

What is an exclusion?

In CSS we can create text wrapped around elements by using floats. If we float an element left or right the following content will wrap around it. However there is no way to float an item right in the middle of some content with text flowing around it.

This is what exclusions do.

The specification doesn’t create a new method of positioning elements, so needs combining with a positioning method. It becomes especially interesting when combined with the upcoming CSS Grid Specification.

In order to take a look I need to use Edge, and therefore the “old” prefixed version of CSS Grid which is implemented in that browser. I’ve added the new syntax as well. If you have IE 10, 11 or Edge then you can take a look at the CodePen examples I have linked.

In the CodePen you can see that I have created a Grid on wrapper which has two child elements, the content in a div with a class of inner and an image which has a class of exclusion. The content I have stretched to cover the entire grid, but the image I have positioned on the grid, it will then sit on top of the content.

By setting wrap-flow: both on the image however it becomes an exclusion. The text knows it is there and flows round both sides of the item.

Exclusions demo 1

View the CodePen for demo 1

You can get pretty creative with this.

Exclusions demo 2

View the CodePen for demo 2

As a quick update to the original post here is an example of using media queries to change the display on viewport width. On narrow windows the exclusions insert the images into the content at full width, at wider windows we have content wrapped on the internal side and the image appearing pulled out of the content.

All of the content is in one article, not broken up by the images in the source.

Here is the CodePen for the responsive example

Grid and Exclusions make sense together

With CSS Grid we can use auto placement to position child elements each in a cell of the grid, enabling a display like this example.

What the addition of exclusions would give us is the ability to define a grid and place items on it – be that images, content, perhaps advertising elements that we don’t want to actually break up an article to insert. Then flow content naturally around that.

No signals

Currently there appears to be no activity around Exclusions. You can see the Chrome Platform Status details here which also lists what other browser vendors and the development community are thinking about this feature. I think it is something we will find useful once Grid ships. I’d love to see other use cases and demos!


This content originally appeared on this is rachelandrew.co.uk and was authored by this is rachelandrew.co.uk


Print Share Comment Cite Upload Translate Updates
APA

this is rachelandrew.co.uk | Sciencx (2016-03-16T12:04:00+00:00) CSS Exclusions and Grid Layout. Retrieved from https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/

MLA
" » CSS Exclusions and Grid Layout." this is rachelandrew.co.uk | Sciencx - Wednesday March 16, 2016, https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/
HARVARD
this is rachelandrew.co.uk | Sciencx Wednesday March 16, 2016 » CSS Exclusions and Grid Layout., viewed ,<https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/>
VANCOUVER
this is rachelandrew.co.uk | Sciencx - » CSS Exclusions and Grid Layout. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/
CHICAGO
" » CSS Exclusions and Grid Layout." this is rachelandrew.co.uk | Sciencx - Accessed . https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/
IEEE
" » CSS Exclusions and Grid Layout." this is rachelandrew.co.uk | Sciencx [Online]. Available: https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/. [Accessed: ]
rf:citation
» CSS Exclusions and Grid Layout | this is rachelandrew.co.uk | Sciencx | https://www.scien.cx/2016/03/16/css-exclusions-and-grid-layout/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.