分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

css透明度、毛玻璃效果

发布时间:2023-09-06 02:34责任编辑:顾先生关键词:暂无标签

 透明度:

1、opacity    背景颜色和字体同时透明

2.background:rgba(255,255,255,0.2);   只是背景颜色透明,字体不透明

 代码:

.info{ ???background-image: url(pineapple.jpg); ???width:300px; ???height:300px;}p{ ???background-color: rgba(255,255,255,0.8); ???opacity:0.2; ???height:100px;}

毛玻璃效果:CSS filter

  • 模糊背景部分,  应用了filter:blur(size)的元素的所有子孙元素都会被模糊处理(不是因为继承),即使子孙元素脱离了该元素的文档流也不能避免。
  • 只对login-box背后部分模糊处理。解决方案是在login-box下层加一个与之重叠的元素,对此元素应用filter:blur(<blur_size>);,可以选择用伪元素:

 代码:

<div class="bg"><!--最外层包裹框,背景图片很鲜艳亮眼position:fixed--> ???<div class=‘blur-box‘> ??????<!--登录表单框部分position:fixed--> ???</div></div>
.bg{ ???background:url(1.jpg) no-repeat center center fixed;/* 与下面的 blur_box:before 中的 background 设置一样 */ ???width:100%; ???height:100%;}.blur_box{ ???z-index: 0;/* 为不影响内容显示必须为最高层 */ ???position: relative; ???overflow: hidden;}.blur-box::before{ ???content:‘‘; ???position:absolute; ?/* 固定模糊层位置 */ ???top:0; ???left:0; ???right:0; ???bottom:0; ???background:url(1.jpg) no-repeat center center fixed;/* 与上面的 bg 中的background设置一样 */ ???filter:blur(10px) contrast(.8); ?/* 值越大越模糊 */ ???z-index:-1; ?/* 模糊层在最下面 */
  /* 还可以设置 width、height 来设置模糊曾的宽和高 */
} ???

css透明度、毛玻璃效果

原文地址:https://www.cnblogs.com/luwanying/p/10469886.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved