这有点难以解释,这就是为什么我也无法在谷歌找到答案。
我正在使用Bootstrap 3,我需要一个全宽背景图像。在那2个透明的彩色背景之上。我做了一个示例图像,以使其清楚:
1 + 2:组合透明色背景
3 + 4:组合透明色背景
1 + 2 + 3 + 4:组合背景图像(最低层)
有谁知道这是否可能以及如何?谢谢你的帮助!
答案 0 :(得分:2)
是的,使用此question中列出的技术,但将其扩展到列。
Codepen Demo(下面)显示的结果比包含在内的Stack Snippet更好。
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
/* prevent scrollbar */
}
.container {
width:80%;
margin:auto;
margin-top: 1em;
position: relative;
overflow: visible;
}
.extra:before {
content: '';
display: block;
/* override bootstrap */
position: absolute;
top: 0;
left: 50%;
width: 100vw;
height: 100%;
transform: translate(-50%, 0);
}
[class*="col"] {
border: 2px solid grey;
min-height: 320px;
position: relative;
}
.left:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
right: 0;
background: rgba(255, 0, 0, 0.5)
}
.right:before {
content: '';
position: absolute;
height: 100%;
width: 100vw;
top: 0;
left: 0;
background: rgba(0, 0, 255, 0.25);
}

<div class="container extra">
<div class="row">
<div class="col-sm-4 left"></div>
<div class="col-sm-8 right"></div>
</div>
</div>
&#13;
答案 1 :(得分:1)
我想我想通了......感谢Paulie_D
很简单的例子:
HTML:
<div class="fullwidth">
<div class="cell red20">xxx</div>
<div class="container cell">
<div class="row">
<div class="col-sm-4 red20">xx</div>
<div class="col-sm-8 red50">xx</div>
</div>
</div>
<div class="cell red50">xxx</div>
</div>
CSS:
.fullwidth {
background: url('http://www.ustudy.eu/nl/wp-content/uploads/2013/10/Test-taking-from-Flickr.jpg');
display:table;
width:100%;
}
.cell{
display:table-cell;
vertical-align:top;
}
.red20{
background-color:rgba(255,0,0,0.2);
}
.red50{
background-color:rgba(255,0,0,0.5);
}
链接到jsfiddle:https://jsfiddle.net/DTcHh/14045/