Text In 'stairs' Layout By Css Or Javascript?
Solution 1:
Here's one possibility in JS. It basically amounts to inserting floated divs of increasing widths, each one line-height high (I colored the divs red to make it more obvious). You could do this straight in the HTML if you wanted too.
var stairsHeight = 500;
var lineHeight = 20;
for (var y = lineHeight; y <= stairsHeight; y+=lineHeight) {
$(".stairs").prepend('<div style="height:' + lineHeight + 'px; width:' + y + 'px; float:right; clear:right; background:red;"></div>');
}
.stairs {width:500px; height:500px; line-height:20px;}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="stairs">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
</div>
Solution 2:
There is a nice tutorial: https://sarasoueidan.com/blog/css-shapes/ .
With such non-standard shape key is polygon()
for either shape-inside or shape-outside . They really did nice illustration so it's easy to understand and apply to your own ideas.
Solution 3:
Css shapes
What you are looking for is called the shape-outside
css property.
Currently only chrome supports this feature.
And if you are wondering on how to use it:
.element {
float: left;
box-sizing: border-box;
shape-outside: polygon(00, 0100px, 100px100px);
-webkit-clip-path: polygon(00, 0100px, 100px100px);
width: 100px;
height: 100px;
background-color: firebrick;
}
span {
vertical-align: top;
}
<divclass="element"></div><p>Lorem ipsum dolar si amet Lorem ipsum
<br>dolar si amet Lorem ipsum
<br>dolar si amet Lorem ipsum dolar si amet Lorem ipsum dolar si amet Lorem ipsum dolar si amet Lorem ipsum dolar si amet</p>
Solution 4:
This might be a png but most definitely it's a canvas, you can draw any shapes using canvas with lineTo x, y coordinates, it uses javascript but even if you are not good with javascript there are really good sources around You can try it here: http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_canvas_tut_path
Post a Comment for "Text In 'stairs' Layout By Css Or Javascript?"