css 例子
This commit is contained in:
47
csspress/demo/margin3.html
Normal file
47
csspress/demo/margin3.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
.box{
|
||||
width:600px;
|
||||
height:300px;
|
||||
background: gold;
|
||||
/* padding-top:50px;
|
||||
border-top: 1px solid white;
|
||||
overflow: hidden; */
|
||||
}
|
||||
.box1{
|
||||
width:50px;
|
||||
height: 50px;
|
||||
background:red;
|
||||
|
||||
/* margin-top: 50px; */
|
||||
}
|
||||
.box2{
|
||||
width:50px;
|
||||
height:50px;
|
||||
background: blue;
|
||||
margin-top: 100px;
|
||||
}
|
||||
.box3{
|
||||
background:pink;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<div class="box1">中国</div>
|
||||
</div>
|
||||
|
||||
<p>总结:当只给中国加上边距时,他外层的父元素也会跟着往下移动 ,这种现象叫父子级的边距合并
|
||||
解决方式:padding-top:50px;
|
||||
border-top: 1px solid white;
|
||||
overflow: hidden
|
||||
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user