CSS实现毛玻璃效果


HTML

<!-- 背景容器层 -->
<
div class="container"></div>
<!-- 遮罩层 --> <div class="mask"></div>

CSS

           body{
			padding: 0;
			margin: 0;
		}
		.container,
		.mask{
			height: 400px;
			width: 100%;
			position: absolute;
			top: 0;
		}
		.container{
			/* background: url(bg.png) no-repeat top/cover; */
			background-image: url(bg.png);
			background-repeat: no-repeat;
			background-position: top;
			background-size: cover;
			/* 高斯模糊 */
			filter: blur(10px); /* 容器四周出现灰色模糊带 */
			z-index: -1;
		}
		.mask{
			background: #333; /* 黑色背景 */
			z-index: -2;  /* 使遮罩层位于背景容器层下方,背景容器模糊带消失 */
		}

测试

/* 给遮罩层加个top,使其和容器背景分开 */
.mask{
    top: 180px;
}

效果

 

最终效果

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM