我有一个具有背景图像的部门,但它需要是可变大小。我正在使用三个图像。一个顶部,一个底部,一个重复的中间。
我只有一个 div 可以使用,并为其提供了中间背景图像,然后使用 before 和 after pesudo 类来放置其他图像。主分区的图像显示在这两个后面,因为它们是半透明的。有没有办法在css中解决这个问题或更好的方法来做到这一点?
高HTML:
<div class="faq">
<strong>Q. Who was the greatest business man?</strong><br />
<p><strong>A. </strong>Noah. He kept his stock afloat, while the rest of the world went into liquidation.</p><br />
<strong>Q. How should my employees let off steam?</strong><br />
<p><strong>A. </strong>Take them see to see the comedian Sampson. He'll bring the house down.</p><br />
</div>
CSS - 样式
.faq{
background: transparent url(../images/image_middle.png) repeat-y center;
color: #ffffff;
display: block;
}
.faq:before {
background: transparent url(../images/image_top.png) no-repeat center top !important;
}
.faq:after {
background: transparent url(../images/image_bottom.png) no-repeat center bottom !important;
}
CSS - 布局
.faq:before {
padding-top: 20px;
display: block;
content: "\A";
}
.faq:after {
padding-top: 14px;
display: block;
content: "\A";
}
.faq{
margin: 20px 0 5px !important;
padding: 0 20px 0 15px !important;
}