html让层悬浮

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/y1535623813/article/details/89021841

1.悬浮在最上层 

 <div style="position:fixed;width:960px;height:30px;text-align:center;top:0px">HTML让层悬浮</div>

传说中的悬浮术

2.悬浮在最右侧  

<div id="uu" style="width:400px; z-index:100; position:fixed; right:20px;top:100px; float:right; background:#eea; ">ee</div>


<div id="dg" style="z-index: 9999; position: fixed ! important; right: 0px; top: 0px;">
<table width=""100% style="position: absolute; width:260px; right: 0px; top: 0px;">
//table 嘻嘻嘻嘻嘻嘻嘻嘻 
</table>

div position参数设置为fixed 其相对于浏览器为绝对位置,通过设置right和top将div固定在右上角。

table position参数设置为absolute,其相对于第一层div绝对定位,通过设置right和top将table固定在div容器的右上角。

扫描二维码关注公众号,回复: 5873841 查看本文章

首先将position定义为,absolute、relative或fixed。 
【必须position为以上三个属性,z-index才能层级体现出来,才能起作用】 
设置 style 中 z-index:auto 
auto可定义为一个值(整数数字),越大代表越置前,如可定义为: z-index:9999。 
若定义为-1,代表为最底层。 
如果要让div1不被div2遮挡,则将div1的z-index设置比div2大就可以了
 

猜你喜欢

转载自blog.csdn.net/y1535623813/article/details/89021841
今日推荐