我有我的div中包含有一个背景图像以下的HTML。这是一幅全宽图像,我希望占用整个屏幕并保持以响应式设计的宽度折叠为中心。我也有一个头,并且具有相同的行为相似的全长图像的页脚,但不是我只显示了中间的形象在这里代码:如何让这个精灵按照我的想法行事?
<div id="contain">
<div id="middle_contain">
<div class="lawyer_select">
<div class="lawyer_hold">
<img src="images/example.jpg" width="252" height="286" alt="stuff" /></div>
<div class="lawyer_hold">
<img src="images/example.jpg" width="252" height="286" alt="things" />
</div>
</div>
</div>
</div>
它具有以下CSS:
#middle_contain{
background-image:url(../images/layout/main-example.jpg);
background-position:center;
background-size:cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.lawyer_hold{
height:312px;
width:480px;
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.7);
float:left;
margin-top:30px;
}
.lawyer_hold:nth-child(2){
float:right;
margin-top:30px;
}
现在,我遇到的情况是,而不是加载中间包含图像加上页眉和页脚图像,我想将它们组合成一个精灵。我无法获得正确的代码,尽管如此,我的图像仍然保持居中等崩溃状态。我已经尝试了以下CSS,它将图像正确放置在我最大的屏幕分辨率上,但是现在,当我折叠其他所有内容时,这些分辨率都会消失。如何正确维护覆盖背景并在使用精灵时保持居中?这是可能的还是应该坚持三个单独的图像?
#middle_contain{
background-image:url(../images/layout/main-example.jpg);
background-position:center;
background-position:0px -167px;
background-size:cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}