css3实现上下半圆

border-radius是可以实现上下左右半圆的,但是如果在整圆里放下半圆,在圆里的位置不太好控制,按照上下左右一个一个介绍

上半圆

image.png
<style>
  .top{
        border-radius: 50px 50px 0 0;
         width: 100px;
        background: #ddd;
        height: 50px;
        display:block;
    }
</style>
<div class="top"></div>

下半圆

image.png
<style>
  .bottom{
        border-radius:  0 0 50px 50px;
         width: 100px;
        background: #ddd;
        height: 50px;
        display:block;
    }
</style>
<div class="bottom"></div>

看这样很容易就出啦上下半圆了

双色圆

如果想在一个整圆中分别作出上下半圆不同颜色,而且圆中带字的话,如图:

image.png

恐怕上面的办法就不好使了,做这种双色圆的方法如下:

<style>
    li {
        position: relative;
        float: left;
        text-align: center;
        width: 100px;
        height: 100px;
        line-height: 100px;
        border-radius: 50%;
        list-style: none;
        padding: 0;
        margin: 20px;
        background: #ddd;
        color: #fff;
    }
    .top {
        border-radius: 50px 50px 0 0;   
        background: #b6caff!important;
        height: 50%;
    }
    .bottom {
        width: 100%;
        height: 50%;
        border-bottom: 50px solid #eff18b;
        border-radius: 50%;
    }
</style>
    <ul>
        <li>
            <div>
                1
            </div>
        </li>
        <li>
            <div class="top">
                1
            </div>

        </li>
        <li>
            <div class="bottom">
                2
            </div>
        </li>
        <li>
            <div class="top bottom">
                3
            </div>
        </li>
    </ul>

我用四个圆做对比,结果如下:


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容