I want to display a list of complex, but fixed-size multiline elements, assuming that they will wrap the page line when line end is reached, making them appear by n
in each row, when
n
depends on page width. Something like:
Mary had Mary had Mary had
a little a little a little
LAMB LAMP WHISKEY
Mary had
a little
TOO MUCH
How should I do that?
The span tag is an inline element that you use to make a smaller part of content stand out with CSS or JavaScript. You shouldn't nest span unless you thoroughly know what you're doing – but you can put multiple span tags within a block-level element.
In practice, the default display of the elements can be changed by the use of Cascading Style Sheets (CSS), although the permitted contents of each element may not be changed. For example, regardless of CSS, a span element may not contain block-level children.
inline-block
spans should do it:
body {
font-family: sans-serif;
}
#container span {
display: inline-block;
width: 5em;
border: 1px solid black;
}
<div id='container'>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
</div>
</body>
</html>
Use a combination of display: block;
float:left;
and your desired width
and height
.
span {
display: block;
float: left;
height: 100px;
width: 100px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With