编辑 2:这是一个使用counter
而不是默认编号的示例。原因是,一旦超过 9,前面示例中的数字开始向左突破:
http ://cdpn.io/izrAh
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
p, ol {margin: 0; padding: 0;}
ol {list-style: none;}
li {
padding-left: 30px;
counter-increment: nums;
position: relative;
}
li:before {
content: counter(nums);
position: absolute;
left: 0px;
}
</style>
</head>
<body>
<p>This is a paragraph of text.</p>
<ol>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
<li>This is a list item<br>
Continuation of list item.
</li>
</ol>
<p>This is a paragraph of text.</p>
</body>
</html>
EDIT1:使用list-style: outside
(默认)更容易:http ://codepen.io/pageaffairs/pen/tiALm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
p, ol {margin: 0; padding: 0;}
ol {width: 150px}
li {margin-left: 18px;}
</style>
</head>
<body>
<p>This is a paragraph of text.</p>
<ol>
<li>This is a list item
Continuation of list item.
</li>
</ol>
<p>This is a paragraph of text.</p>
</body>
</html>
第一次尝试:这样的事情怎么样:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
p, ol {margin: 0; padding: 0;}
ol {list-style: inside; width: 150px}
li {text-indent: -16px; padding-left: 18px;}
</style>
</head>
<body>
<p>This is a paragraph of text.</p>
<ol>
<li>This is a list item
Continuation of list item.
</li>
</ol>
<p>This is a paragraph of text.</p>
</body>
</html>
注意:我刚刚在 上设置了一个小宽度<ol>
来演示换行。另一种方法是在<br>
任何你想要换行的地方使用。