首页 > Web开发 > 详细

CSS的position属性在DIV层中的应用

时间:2016-02-07 07:12:47      阅读:238      评论:0      收藏:0      [点我收藏+]
原来只明白position:relative是相对定位,position:absolute 是绝对定位;

经常看到图片轮播的下方有个半透明背景的文字描述。我现在要做这样一个效果,因为不是轮播,所以没去找插件,想自己写。

半透明背景可以设置属性background: rgba(0, 0, 0, 0.15);

定位的话,父DIV设置position:relative后,子DIV的position:absolute就会相对父DIV作绝对定位。这样就很方便了。

复制代码
代码如下:

.banner{margin:20px;height:204px;position:relative;overflow:hidden}
.banner .content{color:#FFF;font-size:24px;line-height:30px;font-weight:800;background: rgba(0, 0, 0, 0.15);position:absolute;left:0;right:0;bottom:0;}

效果:
技术分享

CSS的position属性在DIV层中的应用

原文:http://www.jb51.net/css/109044.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!