批改状态:合格
老师批语:缺少手写代码!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>定位实现十字架</title>
<style>
body{
margin: 0;
padding: 0;
}
.z{
position: relative;
}
.div1{
width: 100px;
height: 100px;
background:lightskyblue;
position: absolute;
left: 100px;
top: 0px;
}
.div2{
width: 100px;
height: 100px;
background:lightblue;
position: absolute;
top: 100px;
left: 0px;
}
.div3{
width: 100px;
height: 100px;
background:lightcoral;
position: absolute;
left: 200px;
top: 100px;
}
.div4{
width: 100px;
height: 100px;
background: lightcyan;
position: absolute;
top: 200px;
left: 100px;
}
</style>
</head>
<body>
<div class="z">
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
<div class="div4"></div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>元素对齐方式</title>
<style>
.div1{
width: 100px;
height: 100px;
background: lightblue;
line-height: 100px;
text-align: center;
}
.div2{
width: 150px;
height: 150px;
background: lightcyan;
text-align: center;
}
.div2 p{
margin: 0;
line-height: 150px;
}
.div3{
width: 200px;
height: 200px;
background: lightseagreen;
text-align: center;
display: table-cell;
vertical-align: middle;
}
.div4{
width: 200px;
height: 200px;
background: lightpink;
text-align: center;
display: table-cell;
vertical-align: middle;
}
.div4 p{
margin: 0;
}
</style>
</head>
<body>
<div class="div1">div1内容</div>
<div class="div2"><p>div2内容</p></div>
<div class="div3"><a href="#">aaa</a><span>spanspan</span></div>
<div class="div4"><p>p</p></div>
</body>
</html>点击 "运行实例" 按钮查看在线实例

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