为 li 元素设置背景图像
Setting a background image for an li element
如何为 li 元素设置背景图片?
<div id="frame" class="frame bag_item">
<ul class="slidee">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
Jsfiddle 在这里:http://jsfiddle.net/womyhrd8/
这可以像使用 background
(或 background-image
)的任何其他元素一样通过 CSS 完成:
.frame .slidee li {
background: url("http://www.placecage.com/300/50") no-repeat; //add image
float: left;
margin: 0 5px 0 0;
padding: 0;
width: 300px;
height: 50px; //changed just for my example
border: solid black 1px;
}
如何为 li 元素设置背景图片?
<div id="frame" class="frame bag_item">
<ul class="slidee">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
Jsfiddle 在这里:http://jsfiddle.net/womyhrd8/
这可以像使用 background
(或 background-image
)的任何其他元素一样通过 CSS 完成:
.frame .slidee li {
background: url("http://www.placecage.com/300/50") no-repeat; //add image
float: left;
margin: 0 5px 0 0;
padding: 0;
width: 300px;
height: 50px; //changed just for my example
border: solid black 1px;
}