With the shape-outside
CSS property one can define shape values for the float area so that the inline content wraps around the shape instead of the float's box.
CSS
img:nth-of-type(1) {
shape-outside: circle(80px at 50% 50%);
float: left;
width: 200px;
}
img:nth-of-type(2) {
shape-outside: circle(80px at 50% 50%);
float: right;
width: 200px;
}
p {
text-align: center;
line-height: 30px; /* purely for demo */
}
HTML
<img src="http://images.clipartpanda.com/circle-clip-art-circlergb.jpg">
<img src="http://images.clipartpanda.com/circle-clip-art-circlergb.jpg">
<p>Some paragraph whose text content is required to be wrapped such that it follows the curve of the circle on either side. And then there is some filler text just to make the text long enough. Lorem Ipsum Dolor Sit Amet....</p>
In the above example, both the images are actually square images and when the text is placed without the shape-outside
property, it will not flow around the circle on either side. It will flow around the containing box of the image only. With shape-outside
the float area is re-defined as a circle and the content is made to flow around this imaginary circle that is created using shape-outside
.
The imaginary circle that is used to re-define the float area is a circle with radius of 80px drawn from the center-mid point of the image's reference box.
Below are a couple of screenshots to illustrate how the content would be wrapped around when shape-outside
is used and when it is not used.
Output with shape-outside
Output without shape-outside