css遮罩
2012-07-06 01:27
127 查看
css遮罩
图片采用形状透明的(alpha透明度),图片格式为png8。备注:IE6仅支持100%。
使用position定位。父容器relative,子容器absolute。
带形状遮罩层 带颜色透明层 内容层
mask opacity content
有机的结合会美化网站。
示例效果图如下:
<!DOCTYPE html>
<html>
<head>
<title>css遮罩</title>
<style type="text/css">
*{margin:0px;padding:0px;}
body{background:#FFFFFF;}
#test1{width:350px; height:350px; position:relative; overflow:hidden; margin:0px auto 60px;}
.test1_mask{ position:absolute; top:0px; left:0px; width:350px; height:350px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_aa.png) no-repeat; z-index:999;}
#test2{width:400px; height:260px; position:relative; overflow:hidden; margin:0px auto 60px;}
.test2_trans{width:400px; height:260px; background:#FF0000;opacity:0.5;filter:alpha(opacity=50); z-index:99;position:absolute;top:0px;left:0px;}
.test2_mask{ position:absolute; top:0px; left:0px; width:400px; height:260px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_bb.png) no-repeat; z-index:999;}
#test3{width:350px; height:500px;position:relative; overflow:hidden; margin:0px auto 60px;}
.test3_mask{ position:absolute; top:0px; left:0px; width:350px; height:500px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_cc.png) bottom center no-repeat; z-index:999;}
</style>
</head>
<body>
<div id="test1">
<div class="test1_mask" ></div>
<div class="test1_cont"><img alt="" width="350px" height="350px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
<div id="test2">
<div class="test2_mask" ></div>
<div class="test2_trans"></div>
<div class="test2_cont"><img alt="" width="400px" height="260px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
<div id="test3">
<div class="test3_mask"></div>
<div class="test3_cont"><img alt="" width="350px" height="500px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
</body>
</html>
运行代码
图片采用形状透明的(alpha透明度),图片格式为png8。备注:IE6仅支持100%。
使用position定位。父容器relative,子容器absolute。
带形状遮罩层 带颜色透明层 内容层
mask opacity content
有机的结合会美化网站。
示例效果图如下:
<!DOCTYPE html>
<html>
<head>
<title>css遮罩</title>
<style type="text/css">
*{margin:0px;padding:0px;}
body{background:#FFFFFF;}
#test1{width:350px; height:350px; position:relative; overflow:hidden; margin:0px auto 60px;}
.test1_mask{ position:absolute; top:0px; left:0px; width:350px; height:350px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_aa.png) no-repeat; z-index:999;}
#test2{width:400px; height:260px; position:relative; overflow:hidden; margin:0px auto 60px;}
.test2_trans{width:400px; height:260px; background:#FF0000;opacity:0.5;filter:alpha(opacity=50); z-index:99;position:absolute;top:0px;left:0px;}
.test2_mask{ position:absolute; top:0px; left:0px; width:400px; height:260px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_bb.png) no-repeat; z-index:999;}
#test3{width:350px; height:500px;position:relative; overflow:hidden; margin:0px auto 60px;}
.test3_mask{ position:absolute; top:0px; left:0px; width:350px; height:500px; background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_cc.png) bottom center no-repeat; z-index:999;}
</style>
</head>
<body>
<div id="test1">
<div class="test1_mask" ></div>
<div class="test1_cont"><img alt="" width="350px" height="350px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
<div id="test2">
<div class="test2_mask" ></div>
<div class="test2_trans"></div>
<div class="test2_cont"><img alt="" width="400px" height="260px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
<div id="test3">
<div class="test3_mask"></div>
<div class="test3_cont"><img alt="" width="350px" height="500px" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test7.jpg" /></div>
</div>
</body>
</html>
运行代码
相关文章推荐
- jQuery,CSS实现的遮罩层消息显示
- 关于移动端css+js解决遮罩问题方法。
- js css 实现遮罩层覆盖其他页面元素附图
- 微信小程序 利用css实现遮罩效果实例详解
- JS+CSS简单实现DIV遮罩层显示隐藏
- 兼容主流浏览器的jQuery+CSS 实现遮罩层的简单代码
- 记录下遮罩的方法 css不同浏览器下的 透明 设计
- JS+CSS实现弹出全屏灰黑色透明遮罩效果的方法
- CSS+JQuery实现遮罩层淡入淡出的效果
- JS+CSS简单实现DIV遮罩层显示隐藏
- 仿知乎问答颜色渐变遮罩CSS代码
- DIV遮罩层如何实现_Div+CSS教程_CSS_网页制作
- JS+CSS简单实现DIV遮罩层显示隐藏
- JS+CSS简单实现DIV遮罩层显示隐藏
- CSS中的剪裁和遮罩
- CSS页面遮罩
- css图片遮罩蒙板 全局斜线网格覆盖效果
- css遮罩层与fixed
- 从零开始学_JavaScript_系列(17)——CSS<4>(定位、遮罩、float、弹性布局flex)
- js+css实现div遮罩层效果