1. 什么是div
2.如何给div加边框
2.1. 通过CSS设置
<html>
<head>
<style>
.myDiv {
border: 2px solid red;
padding: 10px;
}
</style>
</head>
<body>
<div class="myDiv">
<p>This is my div.</p>
</div>
</body>
</html>
2.2. 通过HTML属性设置
<div style="border: 1px solid black; padding: 10px;">
<p>Hello World!</p>
</div>
2.3. 如何设置边框圆角
<html>
<head>
<style>
.myDiv {
border: 2px solid red;
border-radius: 25px;
padding: 10px;
}
</style>
</head>
<body>
<div class="myDiv">
<p>This is my div.</p>
</div>
</body>
</html>
2.4. 边框样式
<html>
<head>
<style>
.myDiv {
border-style: solid;
border-width: 5px;
padding: 10px;
}
.dashed {
border-style: dashed;
}
.dotted {
border-style: dotted;
}
.double {
border-style: double;
}
</style>
</head>
<body>
<div class="myDiv dashed">Dashed Border</div>
<div class="myDiv dotted">Dotted Border</div>
<div class="myDiv double">Double Border</div>
</body>
</html>
2.5. 边框颜色
<html>
<head>
<style>
.myDiv {
border: 10px solid;
border-color: #FF0000;
padding: 10px;
}
</style>
</head>
<body>
<div class="myDiv">测试红色边框</div>
</body>
</html>
2.6. 更多样式
<html>
<head>
<style>
.myDiv {
border: 10px solid;
border-radius: 25px;
padding: 10px;
box-shadow: 5px 5px 5px #888888;
text-align: center;
background-color: #f2f2f2;
margin: 10px;
}
</style>
</head>
<body>
<div class="myDiv">测试按钮</div>
</body>
</html>