phi*_*ilr 4 html css image background-image css3
我有一个背景图像的div.背景图像css设置如下:
.resPic1 {
background: url(../css/images/residentialpic1.jpeg) center;
background-size: contain;
}
Run Code Online (Sandbox Code Playgroud)
如果你有一个模糊的图像版本,你可以通过在你的元素上应用多个背景图像来实现它:
body {
/* place the blurred image below the normal one */
background-image:
url("https://upload.wikimedia.org/wikipedia/commons/5/55/John_William_Waterhouse_A_Mermaid.jpg"),
url("http://dl.dropboxusercontent.com/s/z3icpq9rkrf4rac/blurred_10px_mermaid.png?dl=0");
/* repeat only the blurred one */
background-repeat: no-repeat, repeat;
background-position: center, center;
background-size: contain;
width: 100vw;
height: 100vh;
}
Run Code Online (Sandbox Code Playgroud)
如果你不这样做,一点::before
+ ::after
黑客也可以做到:
body{
width: 100vw;
height: 100vh;
margin: 0;
}
body::before, body::after{
content: "";
background-image: url("https://upload.wikimedia.org/wikipedia/commons/5/55/John_William_Waterhouse_A_Mermaid.jpg");
background-position: center;
background-size: contain;
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0px;
left: 0px;
}
/* the blurred image */
body::before{
content: "";
background-repeat: repeat;
filter: blur(3px);
}
/* the clear image */
body::after{
content: "";
background-repeat: no-repeat;
z-index: 1;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1589 次 |
最近记录: |