知识学习:
目标:
1、掌握CSS基础属性
2、根据需求搜索对应CSS属性
知识:
1.CSS盒子模型
2、边框
3、定位
练习:完成《花样边框》练习
要求:整体居中于浏览器
颜色提示:gray,brown,white,black,#eeeeee(可更改)
Div数量:6
实验效果:
实验代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
background-color: white;
border: 5px dashed #000000; /*虚线边框*/
margin: 0 auto;
height: 500px;
width: 500px;
position: relative;
}
.box2{
background-color: white;
border: 5px solid gray; /*实线边框*/
/* margin: 0 auto; */
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 400px;
width: 400px;
}
.box3{
background-color: rgb(156, 13, 13);
/* border: 10px solid gray; 实线边框 */
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 300px;
width: 300px;
}
.box4{
background-color: rgb(156, 13, 13);
border: 5px dashed white;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 200px;
width: 200px;
}
.box5{
background-color: rgb(156, 13, 13);
border: 5px dashed white;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 150px;
width: 150px;
}
.box6{
background-color: white;
border: 5px solid black;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 80px;
width: 80px;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2">
<div class="box3">
<div class="box4">
<div class="box5">
<div class="box6">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>