Css <;p>;在100%高度div的垂直中心
我的div高度是100%,但当我这样做的时候,我不知道如何将p标签垂直居中 我该怎么做 HTML:Css <;p>;在100%高度div的垂直中心,css,center,Css,Center,我的div高度是100%,但当我这样做的时候,我不知道如何将p标签垂直居中 我该怎么做 HTML: 一种方法是使用下面概述的方法,请注意,body&html样式是可选的,用于在提供的小提琴中创建更好的插图 关键是需要包含在父元素中,并且两者都需要下面概述的样式 HTML 我还建议您查看一下Ooh抱歉,搜索没有找到这一个,谢谢! <div> <p>This text has to be vertically centered.</div> </div>
一种方法是使用下面概述的方法,请注意,
body
&html
样式是可选的,用于在提供的小提琴中创建更好的插图
关键是
需要包含在父元素中,并且两者都需要下面概述的样式
HTML
我还建议您查看一下Ooh抱歉,搜索没有找到这一个,谢谢!
<div>
<p>This text has to be vertically centered.</div>
</div>
html, body {
height: 100%;
width: 100%;
}
div {
height: 100%;
width: 100%;
background: url(http://www.windsim.com/images/sky/sky_107.bmp) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
p {
font-family: "Times New Roman", Times, serif;
color: black;
text-align: center;
font-size: 65px;
}
<div>
<p>text</p>
</div>
html, body{
height:100%;
width:100%;
margin:0;
padding:0;
}
div {
display: table;
width: 100%;
height: 100%;
text-align: center;
}
p {
display: table-cell;
vertical-align: middle;
}