border-radius 属性用于设置元素的外边框圆角。
语法:
border-radius:length;
参数可百分比,也可是具体px值。
圆角边框也可分开写:
border-radius: 0px 0px 30px 0px; 顺序左上 右上 右下 左下 推荐
以下不推荐
border-top-left-radius 左上角
border-top-right-radius 右上角
border-bottom-right-radius 右下角
border-bottom-left-radius 左下角
代码:
<!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>
div {
width: 400px;
height: 200px;
background-color: #ccc;
/* 1.跟具体的px值,实际使用中自己测试感觉那个合适 */
/* border-radius: 30px; */
/* 2. 跟百分比 跟百分比时最常见的值就是50% */
border-radius: 50%;
}
p {
width: 100px;
height: 40px;
background-color: red;
/* 用高度的一般当作圆角 */
border-radius: 20px;
}
h1 {
width: 200px;
height: 200px;
background-color: skyblue;
/* border-radius: 10px 20px 30px 40px; */
border-radius: 0px 0px 30px 0px;
}
</style>
</head>
<body>
<div></div>
<p></p>
<h1></h1>
</body>
</html>