请老师纠错,谢谢!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS布局</title>
<style type="text/css">
.box{
width: 500px;
height: 200px;
margin:0 auto;
border:1px solid #aaa;
background-color: #ababab;
color: #fff;
font-weight: bolder;
position: relative;
}
.box div{
width: 200px;
height: 40px;
font-size: 16px;
text-align: center;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
}
</style>
</head>
<body>
<div class="box">
<div>
欢迎大家来到慕课网学习!
来到慕课网学习!
</div>
</div>
</body>
</html>PS:请问一下老师我这剧中方式正确吗?还有别的更好的方式吗?谢谢了。
5
收起
正在回答
1回答
同学你好,代码正确。其他方法有:

如果我的回答帮到了你,欢迎采纳,祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星