How to Flow Text Around Shapes in CSS
Use the shape-outside
property in CSS to flow text around elements. You can also use a polygon for more complex shapes:
In the example above, this will create a circle to wrap around the text. By default, text is wrapped around its margin box. With shape-outside
, you can define custom objects to wrap around. To create more complex objects, you can define a polygon
or a path
:
.shape-outside {
shape-outside: polygon(10px 10px, 20px 20px, 30px 30px);
shape-outside: path('path-rule');
}
You can also provide a URL for an image to be used. Make sure it is a png.
.shape-outside {
shape-outside: url(circle.png);
}
Resources:
Rocket Launch Your Career
Speed up your learning progress with our mentorship program. Join as a mentee to unlock the full potential of Webtips and get a personalized learning experience by experts to master the following frontend technologies: