Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css <;p>;在100%高度div的垂直中心_Css_Center - Fatal编程技术网

Css <;p>;在100%高度div的垂直中心

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>

我的div高度是100%,但当我这样做的时候,我不知道如何将p标签垂直居中

我该怎么做

HTML:


一种方法是使用下面概述的方法,请注意,
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;
}