使用自定义列表图像/图标隐藏在列表环绕的浮动元素后面时出现问题。
HTML
<div>
</div>
<ul>
<li>This is list item no 1</li>
<li>This is list item no 2. This is list item no. This is list item no. This is list item no. This is list item no. This is list item no. This is list item no.</li>
<li>This is list item no 3</li>
</ul>
CSS
div {
background: rgba(0,0,0,0.8);
float: left;
width: 100px;
height: 40px;
margin: 0 20px 10px 0
}
li {
padding-left: 1.3em ;
}
li:before {
content: "i";
display: inline-block;
margin-left: -1.3em;
width: 1.3em;
}
注意:我不想添加额外的标记,仅 CSS。
我试过没有负边距(http://jsfiddle.net/9qWGE/),但这会导致长列表出现在图标下