本文内容:页面镂空遮罩层、页面镂空遮罩引导层、图片镂空遮罩
常规遮罩层
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> <title>Title</title> <style> .mask{ position: absolute; width: 100%; height: 100%; top: 0; left: 0; background: rgba(0,0,0,0.4); display: flex; justify-content: center; align-items: center; z-index: 3; } .mask{ position:fixed; top : 0; left : 0; bottom : 0; right : 0; background:rgba(0,0,0,.5); /*background:hsla(0,100%,80%,0.5)*/ /*background:#000; opacity:0.5; */ } //模糊效果 毛玻璃效果 .blur{ -webkit-filter: blur(5px); /* Chrome, Opera */ -moz-filter: blur(5px); -ms-filter: blur(5px); filter: blur(5px); } </style> </head> <style> </style> <body> <div class='mask'></div> </body> </html>
镂空遮罩层效果如图
使用box-shadow实现镂空遮罩引导层效果
优点:
缺点:阴影可视区域无法触发click事件,因此,当点击蒙层任意区域,无法隐藏。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> <title>Title</title> <style> .guide{ position: absolute; z-index: 2; top: 0px; left: 50%; transform: translateX(-50%); width: 50px; height: 50px; border-radius: 50px; border: 3px solid #2353FA; box-shadow: 0px 0px 0px 1000px rgba(0,0,0,.75); box-sizing: border-box; } </style> </head> <style> </style> <body> <div class='guide'></div> </body> </html>
使用border实现镂空遮罩引导层效果
缺点:代码量大
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> <title>Title</title> <style> .guide{ position: absolute; z-index: 2; .opacityEle{ border: 700px solid rgba(0,0,0,0.75); width: 50px; height: 50px; position: relative; top: -700px; left: -538px; border-radius: 50%; .ele{ width: 50px; height: 50px; border: 3px solid #0B6EFF; border-radius: 25px; box-sizing: border-box; } } } </style> </head> <style> </style> <body> <div class='guide'> <div class='opacityEle'> <div class='ele'></div> </div> </div> </body> </html>
到此这篇关于css实现缕空遮罩层的示例代码的文章就介绍到这了,更多相关css缕空遮罩层内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!
1.我向你夸下海口,心为你滴成琥珀,冷却以后,千万年后爱通透依旧。 2.一朝春...
作者:小傅哥 博客: https://bugstack.cn 沉淀、分享、成长,让自己和他人都能...
我们在网页中经常需要控制一些元素的隐藏、透明等属性 style .d1{ display: none...
实现功能: 将桌面图片拖入指定地方,生成相框和相关信息。 相框需要自己配置,...
Gird布局与Flex布局有一定的相似性,都是对容器的内部项目进行划分。 Flex布局是...
突然想到的方法,来试试吧 1.页面布局 canvas id=canva width=500px height=300p...
序号 中文说明 标记语法 备注 1 背景颜色 {background-color:数值} 2 背景图片 {...
需求催动此篇博客的诞生 项目背景 之前也没写过小程序但是看过之后都是现成的api...
前言 何为插件(Plugin)?专注处理 webpack 在编译过程中的某个特定的任务的功能...
在使用dreamweaver或者frontpage来制作HTML网页时,我们有可能会遇到这样的问题...