批改状态:合格
老师批语:你是不是有好几天没上课了, 咱们不断的说, 作业一定要有总结, 不允许直接提交代码了事, 不要应付
1、实例演示如何消除子元素浮动造成父元素高度折叠的影响。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>浮动</title>
<style>
.box1 {
width: 250px;
border: 5px dashed rebeccapurple;
overflow: hidden;
}
.box2 {
width: inherit;
height: 300px;
background-color: lawngreen;
float: left;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
2、 实例演示三列布局的实现原理( 绝对定位实现, 浮动定位实现)。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.box1 {
width: 300px;
height: 600px;
background-color: lawngreen;
}
.box2 {
width: 300px;
height: 600px;
background-color: lightcoral;
position: relative;
left: 300px;
top: -600px;
}
.box3 {
width: 300px;
height: 600px;
background-color: lightblue;
position: relative;
left: 600px;
top: -1200px;
}
</style>
</head>
<body>
<div class="parent">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号