HTML
<ul>
<li>Chapter One - This is chapter one text text text text text text text text</li>
</ul>
How can I accomplish this?
An inline-block element with a set maximum width and corrected vertical alignment is all you need.
Markup snippet:
<ul>
<li>Chapter One - <span class="desc">This is chapter one text text text text text text text text</span></li>
</ul>
Stylesheet snippet:
span.desc {
display: inline-block;
max-width: 10em;
vertical-align: top;
}
The 10em
maximum width is my chosen example value, adjust it according to preference.
Use a definition list ( <dl>
) instead of an unordered list:
<dl>
<dt>Chapter One</dt>
<dd>This is chapter one text text text text text text text text</dd>
</dl>
Now you can float both <dt>
and <dd>
left to bring them next to eachother and you can give <dd>
a specific width.
try
ul li {
text-indent:-50px;
padding-left:50px;
}
text-indent with negative value will move first-line left and whole padding-left will shift everything else back
here is a http://jsfiddle.net/edv7d/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.