Wrapping text around non-rectangular shapes css / html

I read on the website that there is a way to wrap text around non-rectangular shapes, but somehow I don’t know how to do it,

Now I found this link from a question posted here about 3 years ago, then everything changed, if there is an easier way to do this, that would be great.

Here's a good example to give more ideas and website URLs explaining how to do this, but as I said, it's about 3 years.

http://www.torylawson.com/mw_index.php?title=CSS_-_Wrapping_text_around_non-rectangular_shapes

enter image description here

+1
source share
2 answers

Today there is not much choice, if you want to use this effect for a cross-browser, and especially for older ones, you need to manually set the floating elements, which will keep the text away from the selected areas.

in futur, we get the following: http://www.w3.org/TR/2013/WD-css-shapes-1-20131203/

demo: http://codepen.io/anon/pen/fmlgp

div {display:table;border:1px solid; background:url(http://www.printable-math-worksheets.com/images/Polyhedron.gif) center 100px no-repeat; background-size:150px 150px; width:600px;margin:auto;} div p {display:table-cell;padding:0.25em;} p:first-child {border-right:1px solid;} p::before { content:''; float:right; border-left:solid rgba(0,0,0,0.2);/* demo purpose */ padding-top:125px; } .cssShape { float:right; clear:right; background:rgba(0,0,0,0.2);/* demo purpose */ width:15px; height:1.2em; margin:0; } .right .cssShape { float:left; clear:both; } .left .cssShape + .cssShape{ width:25px; } .left .cssShape + .cssShape + .cssShape, .right .cssShape + .cssShape + .cssShape + .cssShape { width:45px; } .left .cssShape + .cssShape + .cssShape + .cssShape, .left .cssShape + .cssShape + .cssShape + .cssShape + .cssShape + .cssShape + .cssShape{ width:60px; } .left .cssShape + .cssShape + .cssShape + .cssShape + .cssShape{ width:70px; } .left .cssShape + .cssShape + .cssShape + .cssShape + .cssShape + .cssShape { width:60px; } .right .cssShape + .cssShape + .cssShape { width:25px; } .right .cssShape + .cssShape + .cssShape + .cssShape + .cssShape{ width:20px; } .right .cssShape + .cssShape + .cssShape { width:60px; } .right .cssShape + .cssShape { width:70px; } .right .cssShape { width:60px; } 

HTML for testing

 <div> <p class="left"> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p> <p class="right"> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> <span class="cssShape"></span> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p> </div> 
+2
source

The CSS Shapes shape-outside property is now widely supported in Chrome, Safari, and Opera.

There is no support in IE or Firefox as of June 2015, but this should not stop you from using progressive enhancement and serving a simple rectangular shape for these browsers.

This article is a good starting point for learning how to use CSS forms for layout: http://www.chenhuijing.com/blog/why-you-should-be-excited-about-css-shapes/

I do not recommend the stacked items method. Despite the fact that it gives the desired effect, it also creates code that is difficult to maintain and reason about.

Keep it simple, affordable, and provide additional features that enable the capabilities of its own browser. In every browser there is no need to look the same the same.

0
source

Source: https://habr.com/ru/post/1235614/


All Articles