肥什么拱门成语| 子宫内膜炎什么症状| 羲什么意思| 全员加速中什么时候播| 孩子晚上睡觉磨牙是什么原因| 黄花菜长什么样子| 1997年是什么生肖| 什么食物降血糖| 旦辞爷娘去的旦是什么意思| 什么歌最好听| 工作性质是什么意思| 妇科和妇产科有什么区别| 鼻子突然出血是什么原因| 男人跑马是什么意思| 薛字五行属什么| 1971年属什么生肖| 得艾滋病的人有什么症状| 水果皇后是什么水果| 什么的绽放| 嗓子疼咽口水都疼吃什么药| 什么是押韵| 腿弯处的筋痛是什么原因| 2333是什么意思| 乐五行属什么| 阴道黑是什么原因| c反应蛋白是查什么的| 脾湿热吃什么中成药| 无花果有什么营养| 安全期什么时候| 双肺纤维灶是什么意思| 发际线长痘痘是什么原因| 小孩口腔溃疡是什么原因| 空调为什么要加氟| 肩胛骨缝疼挂什么科| 盐酸苯海索片治什么病| secret是什么意思| 大蒜吃多了有什么坏处| 朱门是什么意思| 外阴苔癣是一种什么病| 舌头尖有小红点这是什么症状| 留守儿童什么意思| 尿胆素1十是什么意思| 避孕环是什么样子图片| 鸡是什么动物| 梦到乌龟是什么意思| 心阴不足吃什么中成药| 为什么一热身上就痒| 宝宝细菌感染吃什么药| 三七长什么样| 吃什么排湿气最好最快| 这个表情是什么意思| 闪回是什么意思| 水保是什么| 喝红糖水有什么好处和坏处| 得寸进尺是什么生肖| edc是什么意思| cob是什么意思| 潇字五行属什么| 眼睛屈光不正是什么| 儿白是什么意思| 用什么药膏能拔去粉瘤| 嗜酸性肉芽肿是什么病| 脚抽筋是什么原因引起的| 封心锁爱什么意思| 尿臭是什么原因男性| 强化是什么意思| 三国演义是什么朝代| 申属于五行属什么| 尿白细胞加减什么意思| 白内障是什么原因引起的| 中字五行属什么| 男生为什么要做包皮手术| dtc是什么意思| 简直了是什么意思| 为什么医院不开金刚藤| 回苏灵又叫什么| 眼睛模糊是什么原因引起的| 拜阿司匹林什么时间吃最好| hsg是什么检查项目| 为什么会肚子疼| 第一顺位是什么意思| 阴茎进入阴道是什么感觉| 三查八对的内容是什么| 胃胀气是什么原因引起的| 置之死地而后生是什么意思| 酸菜鱼里面加什么配菜好吃| 血小板压积偏低是什么意思| 业火是什么意思| 嘴唇是紫色的是什么原因| 杀鸡给猴看什么意思| ab型和o型生的孩子是什么血型| 金克木是什么意思| 参天大树什么意思| 暖味是什么意思| 灰色是什么颜色| 八月出生的是什么星座| 老心慌是什么原因| 水牛吃什么| 唯利是图是什么生肖| 度蜜月什么意思| 戒指戴左手中指是什么意思| 痛风能喝什么饮料| 车万是什么意思| 夏天都有什么花| 疱疹有什么症状| 早餐吃什么最好| 不想怀孕有什么办法| 心律不齐是什么原因引起的| 眼白发红是什么原因| 孝喘吃什么药好| 拔了牙吃什么消炎药| 胃肠炎可以吃什么水果| 经期同房会有什么后果| 冰种翡翠属于什么档次| 萎缩性胃炎吃什么药最好| 吃什么对肝脏好| 话少一般都是什么人| 左肺纤维灶什么意思| 陌上花是什么意思| 上升水瓶座为什么可怕| 什么是溶血症| 苡字五行属什么| LOP是什么胎位| 公积金基数是什么意思| 三千年前是什么朝代| 为什么吃辣的就拉肚子| china的形容词是什么| 物竞天择是什么意思| 为什么尽量不打免疫球蛋白| 鱼的尾巴有什么作用| 低压高吃点什么药| 水泻拉肚子是什么原因| 磨砂膏有什么作用| 堂哥的女儿叫什么| 昭觉寺求什么最灵验| 车厘子是什么| 海松茸是什么东西| 手麻吃什么药| 12月24号是什么星座| 属猪五行属什么| 唐筛临界风险是什么意思| 产生幻觉是什么原因| 包皮什么意思| cvt是什么意思| scarves什么意思| 婕字五行属什么| 母螳螂为什么要吃公螳螂| 走路脚后跟疼是什么原因| 丈夫早亡的女人什么命| 皮肤粗糙缺什么维生素| 左氧氟沙星氯化钠注射作用是什么| 亚甲炎是什么病| pdd是什么| 威士忌兑什么好喝| 什么是跳蛋| 心口下面疼是什么原因| 黑茶有什么功效| 海鲜不能和什么水果一起吃| diss是什么意思| 灰色裤子配什么上衣好看| 摩羯座是什么星象| magnesium是什么意思| 明年是什么年啊| 拉肚子吃什么好得快| 宝宝体检挂什么科| 汗毛长的女人代表什么| 尿潜血是什么病| 渡劫什么意思| 土崩瓦解是什么意思| 间接是什么意思| 什么东西补肾最好| 气血不足是什么引起的| 吃饭流汗是什么原因| 贴膏药发热是什么原因| 吃什么食物帮助睡眠| 赵字五行属什么| 阴历六月十九是什么日子| spiderman是什么意思| 国潮是什么| 籺是什么意思| 备孕需要补充什么| 天下乌鸦一般黑是什么生肖| 前列腺炎吃什么药好| 蚊虫叮咬用什么药膏| 剁椒鱼头属于什么菜系| 忌神是什么意思| 依赖一个人是什么意思| 茉莉花长什么样| 146是什么意思| 术后引流管什么时间可以拔| 玉髓是什么| 总胆固醇高是什么意思| mr什么意思| 均为是什么意思| 什么饮料好喝| 贲临是什么意思| 15号来月经排卵期是什么时候| 苹果跟什么榨汁好喝| 壁厚是什么意思| 胃下垂吃什么药| 三妻四妾是什么意思| 女人补铁有什么好处| 口苦是什么毛病| 什么鱼最好吃| 结肠炎吃什么中成药| 发狂是什么意思| 梦见家里办丧事是什么预兆| 卵巢过度刺激综合症是什么| 眉毛上方有痣代表什么| 咬肌疼是什么原因| 耳朵红热是什么原因| 锌是补什么的| 更年期失眠吃什么药效果好| 有什么故事| 乘务长是干什么的| 官方的意思是什么| 冰释前嫌是什么意思| 健康证都检查什么项目| 袖珍人是什么| 位数是什么意思| 犬瘟是什么原因引起的| 斯文败类是什么意思| 十全十美是什么意思| 小儿病毒性感冒吃什么药效果好| 什么是丁克| 今年30岁属什么生肖| 公假是什么意思| 骨头受伤了吃什么恢复的快| 一什么小狗| eu是什么元素| 梦见吃水饺是什么预兆| 心包积液挂什么科| 缺氯有什么症状怎么补| 咳嗽吃什么药好| atp 是什么| 血压200意味着什么| 什么是干冰| 拉屎发黑是什么原因| 小孩呕吐是什么原因引起的| 菩提萨婆诃是什么意思| 警察在古代叫什么| 眼睛痛吃什么药好得快| 什么东西最补肾| 得艾滋病的前兆是什么| 嗓子痒干咳是什么原因| 以马内利什么意思| 二聚体是什么| 空字五行属什么| 小孩经常尿床是什么原因| 副支队长是什么级别| 鼻窦炎有什么特效药| 芊芊是什么意思| 谨记的意思是什么| 囊肿是什么原因造成的| 上热下寒吃什么药| 黄豆吃多了有什么坏处| bambi什么意思| 阴茎勃起不硬吃什么| 夏至是什么节日| 风吹动窗吹动夜声响是什么歌| 什么是科学| 柠字五行属什么| 龙冲什么生肖| 苹果有什么功效和营养| 百度
This website is currently in the process of being refactored and redesigned. So if you see anything broken, that's why.

Информации на двух языках

百度 第二天,在训练中老爷子依然不见笑脸,满脸的严肃。

Today we can create all kinds of shapes with CSS using CSS transforms, but all these shapes do not affect the flow of the content inside or around them. That is, if you create a triangle or a trapezoid with CSS, for example, the shape created does not define or affect the way the text inside it flows, or the way inline text around it does.

With the introduction of CSS Shapes into the web, wrapping content in custom non-rectangular shapes, and recreating print designs and layouts on the web becomes a piece of cake!

In this article we're going to go over the basics of declaring shapes, and creating some simple layouts using these new CSS technologies. When more CSS Shapes features are implemented, more complex and awesome layouts will be possible, but even with what we have at hand now, some interesting and very creative layouts can be created with a little extra experimentation.

The CSS technologies we’ll be covering in this article may not work in your browser. If you want to see the working live demos you need to make sure you’re viewing them in a browser that supports these technologies. Check the current state of browser support for CSS Shapes out. You don't need a supporting browser to understand the features and demos, though. I've included screenshots of the demos so you can see how the final result looks like.

Most of this article's demos use the shape-inside property, which has been temporarily removed from Webkit and Blink. So, for the time being, this article will only show screenshots of how the demos work when shape-inside is implemented again.

All HTML elements have a rectangular box model which governs the flow of content inside and around it. In order to give an element a custom non-rectangular shape, the shape-inside and shape-outside properties are used. At the time of writing of this article, the shape-outside property can be applied to floating elements only, and the shape-inside property isn't completely implemented, so you may still find bugs when u use it. The shape-* properties can also only be applied to block-level elements. Non-block-level elements should be forced to block if you want to use a shape property on them.

Shape-* properties take one of three values: auto, a basic shape, or an image URI. If the value is set to auto, the element’s float area uses the margin box as normal. (If you’re not familiar with the CSS box model, make sure you read up on it because you should know how it works).

If the value is set to a shape function, then the shape is computed based on the values of one of ‘inset’, ‘circle’, ‘ellipse’ or ‘polygon’. You can learn more about each of these functions in this article by the Adobe Platform team.

And finally, if the value is set to an image URI, the browser will use the image to extract and compute the shape based on the image’s alpha channel. The shape is computed to be the path that encloses the area where the opacity of the specified image is greater than the shape-image-threshold value. If the shape-image-threshold is not specified, the initial value to be considered is 0.5. The image should be CORS-same-origin, otherwise, it won't work, and the default value auto will be the value of the computed shape.

Shapes defined using the shape-outside property define the exclusion area on an element, while those defined using the shape-inside property define the float area of an element. We'll learn what each of these means in the examples below.

The shapes defined by the shape-* properties can be modified by using the shape-margin and shape-padding properties. The margin and padding shape properties are self-explanatory.

For the CSS shape declared to actually be applied on an element, we need to first start with establishing a coordinate system which we’ll be using to draw the shape.

A coordinate system is necessary because the shapes you declare will be defined by a set of points (and radii if you’re drawing circles or ellipses for example), and these points have x and y coordinates which will be placed on this coordinate system.

The shape-* properties use the content box of the element they’re applied to for their coordinate system, so in order to make them work, you need to specify a fixed width and height for the element which defines its bounding box, which in turn will be used to establish the coordinate system for the shapes you draw. If no explicit width and height are specified, the shape-* properties don’t work.

The origin of the coordinate system defined on the element's bounding box is positioned at the top left corner.

So, to declare a shape an element you have to start with:

  1. Specifying the dimensions of the element getting the shape (remember: the element should be floated when using shape-outside on it).
  2. Declaring the shape on that element using the shape-* properties.

While the boundaries used for wrapping inline flow content outside a float can be defined using shapes, the actual box model does not change. If the element has specified margins, borders or padding they will be computed and rendered according to the CSS3BOX module. W3C CSS Shapes Module Level 1

In other words, the shape you define on an element using shape-* properties only affects the element’s float area, i.e. the flow of the content inside/outside this element, but all the element’s other properties won’t be affected.

For example, suppose you only want to draw a circular shape and have content float on its side like the shape in the image below, you’d first have to declare the circular shape on the element (again, remember to float the element and give it a height and width). Then, say you want to apply a background color to the circular shape to look like the one in the image..

Background applied to CSS shape
Background applied to a custom declared shape

You’d be tempted to just add a background color to the containing element and then end up with the above result (that’s what I did the first time), but doing that won’t do the job. The reason for that is that all properties of the element, other than the flow of content outside it, won’t be affected by the shape you defined inside it, and they will be rendered normally according to the element’s box model (its rectangular shape), as we’ve seen in the spec. So if you apply a background color to it, you’ll end up with this.

Background applied to rectangular box model
Background applied to the element's rectangular box shape

So, how can we apply the color to the shape only and not the whole element? This is where the clip-path property from the CSS Masking specification can help.

The clip-path property will be used to clip parts of the element that we don’t need and keep only the parts inside the shape we defined. That obviously means that we’re not actually applying the color to the shape, we’re just trimming the element and leaving only the shape intact. With this, you’ll end up with a floating circle wrapping text outside it.

How, exactly? what value does the clip-path property get to do this?

The user coordinate system for the shapes defined by the clip-path property is established using the bounding box of the element to which the clipping path is applied, so the coordinate system is the same one as that of the shape-* properties.

Because of this, we can use the same shape defined in the shape-* property for the clip path, which will cut out, or clip, everything inside the containing element that’s outside the boundaries of the shape, and we’ll end up with a custom shape with a background.

You can test this concept live in this pen, just make sure you test it in a supporting browser.

At the time of writing of this article, the shape-outside property only works on floats, and both shape-outside and shape-inside properties are applied only to block-level elements, or inline elements forced to block. A shape defined on a float will cause inline content to wrap around the defined shape instead of the float's bounding box. Future levels of CSS Shapes will allow use of shapes on elements other than floats, and when that happens we’ll be able to wrap content on both sides of a shape (as in the image below). So for now, we can only float an element and have content flow on either side of it.

Example rendering of circle shape and box model.
Flowing content on both sides of a CSS shape

You could also fake wrapping content on both sides using the Exclusion Punch plugin by Bear Travis.

Now let’s get our hands dirty drawing some shapes and creating some fun layouts!

Each of the following examples will introduce a new tip/idea/technique that are used to define and use CSS shapes and exclusions.

You can view the live demo for each example by clicking on the demo's screenshot.

We’ll start with a simple example. In this example we’re going to define a custom shape and have content flow on its side. The end result will look like the image below:

Screenshot of Demo #1
Screenshot of Demo #1. Click on the screenshot to see the working demo.

In the demo we have a container which contains two elements: a .content container with text on the left, and another element with a class.shaped floated to the right, which will get the custom shape and have the text flow on its left side.

The heading in the .content area is also getting a similar treatment to the one we're giving the floated div on the right, so I'll skip its explanation and only talk about what we're doing on the .shaped area on the right.

<div class="container">
<div class="shaped"></div>
<div class="content">
<h1><span>La</span> Tour <br/>Eiffel</h1>
<p>Lorem Ipsum......</p>
</div>
</div>

We will first start by giving the floated div on the right a specific height and width to establish a coordinate system. We’ll set its height to be the same as its container, which for this demo I’ve set to be the same height as the viewport, using CSS’s vh unit.

.container{
overflow:hidden;
height: 100vh;
width: 100vw;
}
.shaped{
float:left;
height:100vh;
width:40vw;
float:right;
background: black url(../images/eiffel.jpg) center top no-repeat;
background-size:cover;
}

Now that the coordinate system is ready, we’re going to draw the shape, to define the float and exclusion areas of the element. There are two ways to go about declaring a shape for this demo:

For the first method, we’ll be using the polygon() function. This function takes in a set of points that form the polygon, each point defined by x and y coordinates. We're going to define a very simple polygonal shape, with 4 vertices, as shown in the image below (blue and orange discs):

Vertices of the Polygon
Screenshot showing the vertices making up the polygonal shape

The coordinates of the points can have either specific values (px or em), or percentage values. In this example we're going to provide percentage values for the vertices visible in the above screenshot. Now all we have to do is just declare this shape on the floated element so that the text flows on its side.

.shaped{
/*...*/
shape-outside: polygon(0 0, 100% 0, 100% 100%, 30% 100%);
shape-margin: 20px;
}

And that’s it! the text can now flow in the float area of the element, defined by the custom shape we declared on it.

You can also see that I've added a margin to the shape, to push the content away from the shape a little and create a gap.

But we have one more thing to add here. Like I mentioned in a previous section, the background of the floated element is applied to its original rectangular shape, not just to the shape we declared on it, because the background property is not affected by the shape declared on the element. So far, the demo looks like this:

Screenshot of background applied to rectangular shape of the element
Screenshot showing the background applied to the element covering its rectangular shape

So in order to clip out the excess areas that we don't need, we're going to use the clip-path property, and give it the same value/shape that we gave to the shape-outside property above. So we add this rule to the rule set:

.shaped{
/*...*/
clip-path: polygon(0 0, 100% 0, 100% 100%, 30% 100%);
}

And we're done! Simple, right?

The page title on the left gets the same treatment as the .floated div on the right. The heading is floated inside its container .content, it is given a specific height and width to establish a coordinate system, and then a shape is declared on it using the shape-outside property just like we did on the .floated element.

Another way we could define the shape on our element is by using an image with an alpha channel, that is, any image with transparent areas.

For our example here, instead of using the polygon() function to define the shape, we’ll give the shape-outside property an image URI, and the browser will extract the shape from the image, and use it.

The image that would define the exclusion area for this example is the one shown below. You can see that the image shows the same shape defined by the polygon() points in the previous method.

Image with Alpha Channel showing the polygonal shape
Image with Alpha Channel whose URI will be used to extract and compute the value of the shape

When you’re using an image with alpha channels to define a shape for the shape-outside property, the transparent area of the image will define the area where the inline text flows, this is the area called the float area of the element. The black portion defines the exclusion area of the element.

To use this image we write the following:

.shaped{
/*...*/
shape-outside: url(../images/mm.png);
shape-image-threshold: 0.5;/* this property is used to set the threshold used for extracting a shape from an image. 0.0 = fully transparent and 1.0 = fully opaque */
}

Each of the two methods mentioned has its advantages. You might want to use an image URI for complex shapes that may be cumbersome to define the points for manually, in this case creating an alpha channel image in Photoshop would be much easier and faster than manually adding the points.

Another situation where you might want to use an image URI instead of a shape function is when you have multiple float or exclusion areas inside an element, in that case using this method is necessary because you can’t, for now, declare multiple shapes on an element, but if the image contains multiple areas, the browser will extract these areas from the image and use them. Pretty neat, right? :) we’ll see an example of this in the last demo.

For the second example we’ll create a simple demo where the end result will look like this:

Screenshot of demo #2
Screenshot of demo #2

The goal of this example is to demonstrate the shape-inside property used to float text inside a non-rectangular shape. We have a container element with some placeholder text inside it, and we applied the photo as a background image to this container.

<div class="container">            
<div class="content">
<p>...</p>
</div>
<h2>Corn Bread</h2>
</div>

As you can see from the demo screenshot above, the text is wrapped inside a circular shape at the top. So, we know that we’re going to have to declare a circle on our container. Now, like in the previous example, there are two ways we can do that..

Using the circle() function we're going to define a circle and position it on our element.

The image below shows the coordinate system established on the element, and the position of the circle inside the element. We’re making sure the circle is positioned on top of the pan image inside the photo we’re using as a background, so that it appears as if the text is contained inside that pan. On the image the position of the center of the circle with respect to the coordinate system established on the element is also visible.

Coordinate system and shape defined on the container
Coordinate system and shape defined on the container

Because we want to wrap text inside a custom shape, and not flow it around it, we’re going to use the shape-inside property on the element containing this text. When you're applying the shape-inside property to an element, you have to remember that this element would have the text content inside it, unlike the previous example, where the content was outside the element we declared the shape on.

We’ll specify the coordinates of the center of the circle and we'll set the value of its radius, and apply those to the container:

.container{
float:left;
width:600px;
height:900px;
overflow:hidden;
margin:0 50px;
color:white;
font-size:13px;
padding:10px;
background: url(../images/pan.jpg) top left no-repeat;
background-size:100% 100%;
/*declare shape using the shape function circle()*/
shape-inside: circle(160px at 400px 60px);
}

Of course, unless you're attempting to create a perfect circular shape, you can also define the shape using polygon().

Using an image URI

We can also use the URI of an image with an alpha channel to extract the shape of the circle from it. The image would look like the following:

Image with Alpha Channel showing the circular shape
Image with Alpha Channel defining the circular shape

It’s important to note here that when you’re using an image with an alpha channel to define a shape for the shape-inside property, the black (or opaque) area of the image will define the area where the text flows. In the previous example, the opaque area defined the exclusion area of the element we applied the shape to, i.e the area where no text flows.

So declare the shape using an image URI instead of the shape function circle(), you'll have to set the value of the shape-inside property to point to the URI of the image:

.container{
/*...*/
shape-inside: url(mask.png) top left;
}

In this example we're also going to declare a polygonal shape on a container and have its content flow inside this shape. The end result will look like the image below:

Screenshot of Demo #3
Screenshot of Demo #3

Here, too, we can use either a shape function or an image URI to declare the shape on the element.

The shape declared on this container is clearly a "random" polygonal shape, not a geometric shape that we could declare using a shape function like circle(), ellipse(), or inset(), so we're going to use the polygon() function to declare it.

The shape defined by a set of points is visible in the image below.

The polygonal shape defined by a set of points
The polygonal shape defined by a set of points

Because there's a fairly large number of points making this shape up, it would be cumbersome to calculate the coordinates of these points, so it would be helpful if there was a visual tool available to help us plot these points on the image, right? Well, there is a tool created by Adobe's Bear Travis, which is actually a collection of tools that can help you when working with CSS shapes. Make sure you check the Shape Tools out because they are very valuable.

One of the Shape tools mentioned is called Poly Draw, and it allows you to manually "draw" a shape, a polygon in particular, and then it generates the coordinates of the shape for you to copy and paste into your CSS to declare the shape on your element.

I have used the Poly Draw tool to draw the above shape on the image. Now, the tool does not take an image and sets it as a background for the element you define the shape on, so I had to git clone the repo of the tool and fiddle with the tool’s code a bit in the dev tools, and I applied the image to it and plotted the points on it.

Razvan Caliman suggested this idea when I asked him about the availability of a tool that allows us to define shapes on top of images right in the browser, just like the one he showed and used in his talk at this year's CSS Conf EU. If you haven't watched his talk yet, make sure you do. The tool he used will some day, soon I hope, be open-sourced by Adobe, and then it'll be an indispensible tool when working with CSS shapes. But until then, you could do with the Poly Draw tool.

After drawing the shape with the Poly Draw tool, all you have to do is declare the resulting shape on your element and you're good to go.

.container{
width:445px;
height:670px;
overflow:hidden;
margin:30px auto;
/*shape generated by the Poly Draw tool*/
shape-outside: polygon(170.67px 291.00px,126.23px 347.56px,139.79px 417.11px,208.92px 466.22px,302.50px 482.97px,343.67px 474.47px,446.33px 452.00px,443.63px 246.82px,389.92px 245.63px,336.50px 235.26px,299.67px 196.53px,259.33px 209.53px,217.00px 254.76px);
}

We could also define the shape above using an image with an alpha channel. The image below shows what that image would look like. Again, the black areas define the float area when using shape-inside, and they're where the text is going to flow.

Image with alpha channel defining the shape for demo #2
Image with alpha channel defining the shape for demo #2

If you want to go with the image URI instead of the shape function, youd replace the above shape outside value with the following:

.container{
/*...*/
shape-inside: url(mask.png) top left;
}

In this example we're going to create multiple float areas inside an element to wrap content inside. The result of this demo is shown in the following image:

Screenshot of Demo #3
Screenshot of Demo #4

We have a div with a background image, and we want the text inside this div to flow inside specific areas inside it, all of which have custom shapes.

<div class="container">
<div class="content">
<h2>Rosemary Sandwich</h2>
<p>...</p>
</div>
</div>

Now, since we can't declare multiple shapes on an element, we're going to use an image with an alpha channel. An image can contain as many shapes and areas as you want, so it's perfect to define multiple shapes on an element, and the browser will extract all the shapes from this image and use them on the element.

We'll use the following image to define the shapes. The black areas in the image will define the float area of for the content inside the .container where the text will flow.

Image with Alpha Channel defining shapes for demo #3
Image with Alpha Channel defining shapes for demo #3

We'll use the URI of this image as a value for the shape-inside property that we're going to declare on the .container, all the while remembering to set height and width values for the div:

.container{
width:556px;
height:835px;
overflow:hidden;
margin:0 50px;
color:white;
position:relative;
background: url(../images/bread.jpg) top left no-repeat;
background-size: 100% 100%;
shape-inside: url(mask.png) top left;
font-size:13px;
}

And we're done. The browser does the rest of the work for us by extracting the shapes from the image we gave it, and our text flows nicely inside those areas!

Using an image to define the shapes is the logical way to go when you have separate areas that are not connected to eachother, i.e that don't form a singe polygonal shape. For this demo, we could have used the polygon() function to define the shape, by defining a polygon that looks like the one in the image below:

Image of shape defined using polygon()
Image representing the points used to define a single polygon

But, as you can notice, this isn't the best way to do this, I just added this to show the difference between using an image and defining the shape with polygon(), and to show that sometimes the best practice or the one that seems more proper and makes more sense is to use an image, even if you can use a shape function to define your shapes.

Typical print magazines usually combine multi-column text layouts with non-rectangular shapes to create creative and appealing designs. The columns are usually equal in height unless needed otherwise.

Once future CSS Shapes features are implemented, and wrapping content on both sides of a shape is possible, creating print-like digital magazine designs becomes very much possible when combining Shapes and Exclusions with Regions and Flexbox.

Multi-column layouts with shapes
Travel Magazine by Bartosz Kwiecień on Behance. Layout like this could be replicated using future CSS Shapes technologies and Regions ()

Flexbox provides us with the equal-height columns, Regions allows us to flow text into different areas on the page and separate the page content from its layout, and Shapes and Exclusions will allow us to add that final creative touch that takes our magazine layouts to the next level.

I don’t think I’ve been excited about a new CSS feature as I am about CSS shapes and exclusions. The power, flexibility, and creativity that these features combined regions and flexbox can provide is just fantastic!

Widespread support for CSS Shapes should be coming soon, as the web platform team at Adobe is constantly working on improving and implementing these features, and providing tools to make working with them easier.

The future of web layout is looking brighter and more captivating every day. It's a wonderful time to be a web developer!

I hope this article helped introduce you more to the technical part of getting started with CSS Shapes. This will not be my last article on this topic. Combining CSS Shapes with other cutting edge CSS technologies like Regions opens the door to a new world of creativity, and lots of new tutorials! ;)

You should subscribe to my blog's RSS feed and follow me on Twitter to stay in the loop for upcoming new articles.

Thank you for reading!

Resources & Further Learning

This article wouldn’t have been possible without the great help from Razvan Caliman, so a big thanks goes to him.



Level up your accessibility knowledge with the Practical Accessibility course!

I created a self-paced, get-right-down-to-it online video course for web designers and developers who want to start creating more accessible Web user interfaces and digital products today.

The course is now open for enrollment!

Subscribe elsewhere

RSS

Get my latest content in your favorite RSS reader. (What is RSS?)


母螳螂为什么要吃公螳螂 特诊科是什么意思 野人是什么意思 阴囊瘙痒用什么药 智商130算什么水平
小孩子晚上睡觉磨牙是什么原因 孕妇做唐筛是检查什么 夏天什么花会开 盲目是什么意思 五味子有什么功效和作用
投资什么好 血压低会导致什么后果 ggo是什么意思 桂枝茯苓丸治什么病 不拘是什么意思
女性胆囊炎有什么症状 施华蔻属于什么档次 美籍华裔是什么意思 巨细胞病毒阳性什么意思 高血压需要注意什么
脑干诱发电位检查是检查什么hcv8jop1ns7r.cn 李耳为什么叫老子hanqikai.com 10月26是什么星座hcv8jop5ns1r.cn 老年人经常头晕是什么原因造成的hcv7jop7ns2r.cn 左手虎口有痣代表什么hcv7jop9ns9r.cn
阴唇肿是什么原因hcv8jop8ns7r.cn 虎虎生风是什么意思hcv9jop6ns7r.cn hpv11阳性是什么意思hcv9jop1ns5r.cn jk是什么意思hcv9jop4ns0r.cn 7.8号是什么日子hcv9jop4ns5r.cn
男士内裤买什么牌子好hcv8jop5ns3r.cn 热伤风是什么意思chuanglingweilai.com 梦到掉头发是什么意思hcv7jop5ns2r.cn 舌苔厚白中间有裂纹吃什么药hcv9jop2ns5r.cn 头疼头晕是什么原因hcv9jop3ns5r.cn
推崇是什么意思bfb118.com 嗓子哑是什么病的前兆hcv8jop0ns8r.cn 手足口病有什么危害hcv8jop1ns3r.cn 牛腩是什么部位的肉wzqsfys.com 腹腔多发淋巴结是什么意思jasonfriends.com
百度