圆角
通过border-radius为盒子设置圆角孤度
语法:
设置一个值:
border-radius:10px;
设置四个值:
border-radius: 左上 右上 右下 左下;
设置两个值:
border-radius:左上右上 右下左下;
原理:
圆角的孤度 是圆的半径决定
属性值:数字(100px)或 百分比(50%)
特殊形状
圆形:盒子为正方形情况下,盒子的border-radius 值为 50%;
椭圆: 盒子为长方型情况下,将盒子的 border-radius 值 设为 50%;
例:
<!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>
.box {
width: 800px;
height: 800px;
background-color: #f2f2f2;
}
.box-1 {
width: 219px;
height: 100px;
background-color: green;
border-radius: 130px 130px 0px 0px;
position: relative;
top: 20px;
left: 250px;
}
.box-2 {
width: 15px;
height: 15px;
background-color: #ffffff;
border-radius: 130px 130px;
position: relative;
top: -25px;
left: 305px;
}
.box-3 {
width: 15px;
height: 15px;
background-color: #ffffff;
border-radius: 130px 130px;
position: relative;
top: -41px;
left: 395px;
}
.box-4 {
width: 220px;
height: 180px;
background-color: green;
position: relative;
left: 250px;
border-radius: 0px 0px 20px 20px;
}
.box-5 {
width: 40px;
height: 150px;
background-color: green;
position: relative;
left: 200px;
top: -175px;
border-radius: 10px 10px 10px 10px;
}
.box-6 {
width: 40px;
height: 150px;
background-color: green;
position: relative;
left: 480px;
top: -325px;
border-radius: 10px 10px 10px 10px;
}
.box-7 {
width: 40px;
height: 80px;
background-color: green;
position: relative;
left: 285px;
top: -290px;
border-radius: 10px 10px 10px 10px;
}
.box-8 {
width: 40px;
height: 80px;
background-color: green;
position: relative;
left: 390px;
top: -370px;
border-radius: 10px 10px 10px 10px;
}
</style>
</head>
<body>
<div class="box">
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
<div class="box-4"></div>
<div class="box-5"></div>
<div class="box-6"></div>
<div class="box-7"></div>
<div class="box-8"></div>
</div>
</body>
</html>
效果图: