位置div中心水平和垂直 [英] position div center horizontal and vertical

查看:115
本文介绍了位置div中心水平和垂直的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是原来的位左边。

我想要一个弹出式窗口的中心。 >

 < div class =popLayerWrapper> 
< div id =addBookmarksLayerclass =popLayerstyle =left:260px; padding:30px;>
< div class =closeLayer> close< / div>
< div class =layerContent>< / div>
< / div>
< / div>


解决方案

不知道我理解你要集中哪个部分,但假设整个事情:

  .popLayerWrapper {
position:absolute;
width:40%; / *可以是任何东西* /
left:50%;
margin-left:-20%; / * half of width * /
height:40%; / *再次,可以是任何* /
top:50%;
margin-top:-20%; / * half of height * /
}


i would like to center a popup div how can i do that browser friendly????

this is the original a bit to the left.

<div class="popLayerWrapper">
    <div id="addBookmarksLayer" class="popLayer" style="left:260px; padding:30px;">
        <div class="closeLayer" >close</div>
        <div class="layerContent"></div>
    </div>
</div>

解决方案

Not sure I understand which part you want to center, but assuming the whole thing:

.popLayerWrapper {
   position: absolute;
   width: 40%;  /* could be anything */
   left: 50%;
   margin-left: -20%;  /* half of width */
   height: 40%;    /* again, could be anything */
   top: 50%;
   margin-top: -20%;  /* half of height */
}

这篇关于位置div中心水平和垂直的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆