css文本样式3-12编程练习
来源:3-12 编程练习
soso_crazy
2018-06-28 21:44:29
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>vertical-align</title>
<style type="text/css">
*{padding:0px;margin: 0px;}
.warp1{
height:80px;
width: 100%;
background-color: #14191e;
/*在此补充代码*/
}
.warp1 h1{ color:#fff;
/*在此补充代码*/
line-height:80px;
text-align:center;
font-size:24px;
}
.warp2{
height:400px;
width: 100%;
border:1px #14191e solid;
/*在此补充代码*/
display:table;
}
.content{
/*在此补充代码*/
vertical-align:middle;
display:table-cell;
text-height:1.5em;
font-size:14px;
text-align:center;
}
.content p{ width:500px;
font-family: "微软雅黑";
margin:0 auto;
/*在此补充代码*/
}
</style>
</head>
<body>
<div class="warp1">
<h1>欢迎来到慕课网</h1>
</div>
<div class="warp2">
<div class="content">
<p>慕课网,只学有用的!</p>
<p>慕课网(IMOOC)是IT技能学习平台。慕课网(IMOOC)提供了丰富的移动端开发、php开发、web前端、android开发以及html5等视频教程资源公开课。并且富有交互性及趣味性,你还可以和朋友一起编程。</p>
</div>
</div>
</div>
</body>
</html>
不能实现垂直水平居中,和效果图不一样,究竟是哪里出错?使用display:table和display:table-sell应该放哪里?
1回答
qq_无尽的路_0
2018-06-29
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>vertical-align</title>
<style type="text/css">
*{padding:0px;margin: 0px;}
.warp1{
height:80px;
width: 100%;
background-color: #14191e;
/*在此补充代码*/
text-align: center;
}
.warp1 h1{ color:#fff;
/*在此补充代码*/
line-height: 80px;
font-size: 24px;
}
.warp2{
height:400px;
width: 100%;
border:1px #14191e solid;
/*在此补充代码*/
text-align: center;
display: table;
}
.content{
/*在此补充代码*/
display: table-cell;
vertical-align: middle;
}
.content p{ width:500px;
font-family: "微软雅黑";
margin:0 auto;
/*在此补充代码*/
width: 500px;
line-height: 1.5em;
font-size: 14px;
}
</style>
</head>
<body>
<div class="warp1">
<h1>欢迎来到慕课网</h1>
</div>
<div class="warp2">
<div class="content">
<p>慕课网,只学有用的!</p>
<p>慕课网(IMOOC)是IT技能学习平台。慕课网(IMOOC)提供了丰富的移动端开发、php开发、web前端、android开发以及html5等视频教程资源公开课。并且富有交互性及趣味性,你还可以和朋友一起编程。</p>
</div>
</div>
</div>
</body>
</html>
display:table 放到父div
display:table-cell放到子div
相似问题