美文网首页CSS3探索
border-radius画圆

border-radius画圆

作者: 钢笔先生 | 来源:发表于2020-01-31 15:22 被阅读0次

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;

分别拿出四个值分别设置,我们还可以分成xy轴来设置。

.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.

相关文章

  • border-radius画圆

    Time: 20200131 维护工作量变小 性能提升 页面更美观 先绘制正方形 显示效果: 圆形 只需要加一行:...

  • border-radius熟悉写形状攻略

    border-radius,国内翻译成圆角,你可能以为这个属性就是用来画圆角,没错,但是除此之外,它还可以做点别的...

  • CSS3属性border-radius参数详解

    border-radius,国内翻译成圆角,你可能以为这个属性就是用来画圆角,没错,但是除此之外,它还可以做点别的...

  • CSS3圆角样式解析

    CSS3的border-radius属性,最常见的也许是被用来画圆形,方法是设置一个正方形div之后,给它的bor...

  • PHP从入门到精通,038第三章HTML5+CSS3——CSS3

    三、border-radius属性 border-radius:圆角

  • CSS3边框

    圆角边框border-radius border-radius属性值的4种写法1、border-radius设置1...

  • CSS 边框的圆角

    重点要记住:border-radius半径(边框圆角使用)border-radius:(左上,右上,右下,左下)(...

  • CSS 圆角

    border-radius

  • 圆角矩形加阴影

    圆角矩形加阴影 圆角 border-radius:左上 右上 右下 左下;border-radius 有更多的功能...

  • border-radius的理解

    一、border-radius: 30px; border-radius: 30px; // 边框的上右下左,都是...

网友评论

    本文标题:border-radius画圆

    本文链接:https://www.haomeiwen.com/subject/sjmgthtx.html