0
只是好奇,为什么我不能在这个跨度/看到我的BG IMG,除非我使用的位置:绝对?!是因为span是一个内联元素吗?跨度与img作为bg
.thumb {
background: url("images/yts.png") no-repeat;
height: 150px;
width: 200px;
}
<span class="thumb"></span>
只是好奇,为什么我不能在这个跨度/看到我的BG IMG,除非我使用的位置:绝对?!是因为span是一个内联元素吗?跨度与img作为bg
.thumb {
background: url("images/yts.png") no-repeat;
height: 150px;
width: 200px;
}
<span class="thumb"></span>
是的。问题在于,对于内联元素,width属性不起作用。因此,没有内容的跨度宽度为0,然后只有背景的零像素可见!
您可以使用display:inline-block来解决这个问题,并且不需要绝对地定位它。