1.边框的简写
2.代码:
<!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>边框的复合写法</title>
<style>
div{
width: 300px;
height: 200px;
/* border-width: 5px;
border-style: solid;
border-color: pink; */
border: 5px solid pink;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
3.运行效果
4.边框可以分开写
上边框:border-top;下边框:border-bottom;左边框:border-left;右边框:border-right
4.案例:请给一个200*200的盒子,设置上边框为红色,其余边框为蓝色
代码:(写法一)
<!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>边框的练习</title>
<style>
div{
width: 200px;
height: 200px;
border-top: 1px solid red;
border-bottom: 1px solid blue;
border-left: 1px solid blue;
border-right: 1px solid blue;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
写法二
<!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>边框的练习</title>
<style>
div{
width: 200px;
height: 200px;
/* border包含了四条边 */
border: 1px solid blue;
/* 层叠性只是层叠了上边框 */
border-top: 1px solid red;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
border包含了四条边
层叠性——border-top只是层叠了上边框