别人如何使用纹理结合作为背景图片和背景颜色纹理之上?CSS:结合纹理和色彩
这里的质地:
我想我的身体背景页是这样:
我与backroung形象和挣扎背景色:http://jsfiddle.net/87K72/
body{
background: #6DB3F2 url('http://s13.postimg.org/j0qiscsw3/cream.png');
}
别人如何使用纹理结合作为背景图片和背景颜色纹理之上?CSS:结合纹理和色彩
这里的质地:
我想我的身体背景页是这样:
我与backroung形象和挣扎背景色:http://jsfiddle.net/87K72/
body{
background: #6DB3F2 url('http://s13.postimg.org/j0qiscsw3/cream.png');
}
您可以使用覆盖DIV与alpha通道你的身体顶部,但在你的其他元素下。
<h1>I want blue color above my texture</h1>
<div id="cover"></div>
body {
background: url('http://i.stack.imgur.com/oslRB.png');
}
h1{
position:relative;
z-index:2;
}
#cover {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background-color:rgba(109,179,242,0.5);
z-index:1;
}
哇,不知道顶/左/底/右= 0技巧得到一个拉伸的div横跨整个视口。太好了! –
使用伪元素可以轻松避免#cover。 –
@Rollyng:该解决方案不适用于允许向下滚动的页面:http://jsfiddle.net/87K72/4/ –
它看起来像你的texture here缺少一个alpha通道。它不是半透明的,它真的是白色的。
你需要使用一个半透明的背景纹理是什么;那么你的CSS指令,将这样的伎俩:
HTML:
<h1>I want blue color above my texture</h1>
CSS:
body {
background: #6DB3F2 url('http://wizzley.com/static/img/bg/texture8.png');
}
检查@ j08691解决方案有一个很好的把戏(必须知道)尽管透明度的值尽管价值透明 – Rollyng
你可以利用CSS不透明的做到这一点。
创建两个div - 一个颜色,一个用于质地:
HTML:
<div class="texture-color">
<div class="texture">
<h1> I want blue color above my texture</h1>
</div>
</div>
CSS:
.texture,.texture-color {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0; }
.texture {
background: #6DB3F2 url('http://s13.postimg.org/j0qiscsw3/cream.png');
opacity: 0.8; }
.texture-color {
background-color: cyan; }
body {
width:auto;
height:auto;
background: green;
}
body:after{
content : "";
display: block;
position: absolute;
top: 0;
left: 0;
background: url(http://i.stack.imgur.com/oslRB.png) repeat;
width: 100%;
height: 100%;
opacity : 0.5;
}
h1{
position:relative;
z-index:2;
}
It应该是“位置:固定”,以使这个页面需要向下滚动。另外,为应该出现在颜色层上的所有元素设置正确的Z-index是一件很乏味的事情。 –
应用背景图片到你的'html'标签,应用背景色为你的'body'标签,并确保它占用了整个页面。 –