浅析CSS-通过百分比画半圆

浅析CSS-通过百分比画半圆

  • 遇到问题:CSS通过border-radius的百分比来画半圆应如何实现?
  • 解决:自行尝试,查阅博客,W3C border-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  type="text/css">
        #div1{
            float: left;
            width: 300px;
            height: 600px;
            background-color: #000;
            border: solid 5px;
            border-radius:  100% 0% 0% 100%/50%;
        }

        /*
         "/"前面的为四个横向半径的值,"/"后面的为四个纵向半径的值
         参考:https://www.jianshu.com/p/ac2629d45713
         https://happy-alex.github.io/css/border-radius/
         https://toutiao.io/posts/f3kjf/preview
        */
        #div2{
            float: left;
            margin-left: 200px;
            width: 600px;
            height: 300px;
            background-color:aqua;
            border: 5px;
            /* border-top-left-radius: 300% 500%;
            border-top-right-radius: 300% 500%;
            border-bottom-left-radius: 0% 0%;
            border-bottom-right-radius: 0% 0%; */
            border-radius:  300% 300% 0% 0%/500% 500% 0% 0%;
        }
    </style>
</head>
<body>
    <div id="div1">

    </div>

    <div id="div2">

    </div>
</body>
</html>
posted @ 2021-08-25 18:28  CN_Darren  阅读(267)  评论(1)    收藏  举报