如何在屏幕的底部中心放置div [英] How do I position a div at the bottom center of the screen

查看:124
本文介绍了如何在屏幕的底部中心放置div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个css:

#manipulate
{
  position:absolute;
  width:300px;
  height:300px;
  background:#063;
  bottom:0px;
  right:25%;
}

我有这个html:

<div id="manipulate" align="center">

</div>

我们如何将div定位在屏幕底部中心? b $ b

How do we position that div at the bottom center of the screen?!?

推荐答案

align =center没有效果。

由于你有 position:absolute ,我建议从左边开始定位50%,然后从左边距减去其宽度的一半。 / p>

Since you have position:absolute, I would recommend positioning it 50% from the left and then subtracting half of its width from its left margin.

#manipulate {
    position:absolute;
    width:300px;
    height:300px;
    background:#063;
    bottom:0px;
    right:25%;
    left:50%;
    margin-left:-150px;
}

这篇关于如何在屏幕的底部中心放置div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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