首页 > 代码库 > CSS垂直居中小结
CSS垂直居中小结
1、设置子元素:
{
...
position :absolute;
margin:auto;
top:0;
right:0;
bottom:0;
left:0;
}
2、设置子元素:(height必须是固定值)
{
position: absolute;
top:50%;
margin-top: - (0.5height);
}
3、设置子元素:(只适用于情况比较简单的单行文本)
{
height:n px;
line-height: n px;
}
4、box 布局
5、transform
{ position: absolute; top: 50%; transform:translateY(-50%); }
CSS垂直居中小结
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。