0

在过去的几天里,我一直在尝试解决这个非常烦人的问题。我什至已经阅读了 Stackoverflow 上所有可能的解决方案,但没有任何效果!

我的 HTML 中有这段代码:

<div id="picture">
   <div class="picture-1"></div>
   <div class="picture-2"></div>
   <div class="picture-3"></div>
</div>

我的CSS中的这段代码:

#picture {
height: 250px;
border-top: 1px solid #ffefaf;
border-bottom: 2px solid #ffffff;
clear: both;
}

.picture-1 {
background: transparent url('images/view.png') left top no-repeat;
}

.picture-2 {
background: transparent url('images/plant.png') left top no-repeat;
}

.picture-3 {
background: transparent url('images/view.png') left top no-repeat;
}

图片在正确的文件夹中,名称正确,但它们不起作用。可能是什么问题呢?

4

3 回答 3

0

您的图片DIV没有尺寸。它们不会像IMG标签那样自动将其大小设置为图像。您需要在 CSS 中使用width:和进行设置height:

于 2013-02-22T16:18:14.243 回答
0

我认为问题在于您的内部 div 没有大小,因此他们尝试将以下几行添加到您的 css:

#picture  > div {
    width: 200px;
    height: 200px;
}
于 2013-02-22T16:25:10.187 回答
0

添加#picture div{height: 250px;}

Js小提琴为您解答-> http://jsfiddle.net/niteshp27/xkLd7/

于 2013-12-04T19:24:46.810 回答