批改状态:合格
老师批语:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>元素对齐</title>
<style type="text/css">
.box1 {background-color:lightskyblue;width:300px;height: 200px;}
.box1>.box2 {width:30%;height:30%;background-color:red;margin:0 auto;}
.box3 {background-color:lightskyblue;text-align:center;width:300px;height: 200px;}
.box3>ul{list-style: none; padding: 0; }
.box3>ul li{ display: inline;}
.box4{background-color:lightskyblue;width:300px;height: 200px;
text-align: center;display: table-cell;vertical-align:middle; }
.box4>.box2{width:30%;height:30%;background-color:red;margin:auto;}
.box5 {background-color:lightskyblue;width:300px;height: 200px; line-height: 200px; text-align: center;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
</div>
<hr>
<div class="box3"><span>单行行内文本</span></div>
<hr>
<div class="box3">
<span>多行行内文本</span><br>
<a href="">水平居中</a>
</div>
<hr>
<div class="box3">
<ul>
<li><a href="">1</a></li>
<li><a href="">2</a></li>
<li><a href="">3</a></li>
<li><a href="">4</a></li>
<li><a href="">5</a></li>
<li><a href="">6</a></li>
</ul>
</div>
<hr>
<hr>
<div class="box4">
<span>单行行内文本<br>
php中文网<br>
</span>
</div>
<hr>
<div class="box4">
<div class="box2"></div>
</div>
<hr>
<div class="box5"><span>单行垂直</span></div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
手写图:

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号