Time: 20200131
- 维护工作量变小
- 性能提升
- 页面更美观
先绘制正方形
<!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>Border Radius</title>
<style type="text/css">
.demo {
width: 200px;
height: 200px;
border: 1px solid #ccc;
background-color: #f66;
/* 下沉50px并居中 */
margin: 50px auto;
}
</style>
</head>
<body>
<div class="demo"></div>
</body>
</html>
显示效果:
截屏2020-01-31下午3.08.16.png
圆形
只需要加一行:
.demo {
width: 200px;
height: 200px;
border: 1px solid #ccc;
background-color: #f66;
/* 下沉50px并居中 */
margin: 50px auto;
border-radius: 50%;
}
这样就变成了圆形。
分别设置四个角
.demo {
...
/* border-radius: 50%; */
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
}
简写法:
border-radius: 100px 100px 50px 50px;
分别拿出四个值分别设置,我们还可以分成x和y轴来设置。
.demo {
border-top-left-radius: 50px 100px;
}
截屏2020-01-31下午3.14.13.png
画半圆
<!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>Border Radius</title>
<style type="text/css">
.left-half-circle {
width: 100px;
height: 200px;
border: 1px solid #ccc;
background-color: #f66;
/* 下沉50px并居中 */
margin: 50px auto;
/* 顺时针 */
/* 左半圆 */
border-radius: 100px 0px 0px 100px;
}
.top-half-circle {
width: 200px;
height: 100px;
border: 1px solid #ccc;
background-color: #f66;
margin: 50px auto;
border-radius: 100px 100px 0px 0px;
}
</style>
</head>
<body>
<div class="left-half-circle"></div>
<div class="top-half-circle"></div>
</body>
</html>
效果如下:
截屏2020-01-31下午3.21.20.png
END.












网友评论