border-radius如何给元素添加圆角边框 border-radius给元素添加圆角边框方法

作者:袖梨 2022-06-25

本篇文章小编给大家分享一下border-radius给元素添加圆角边框方法,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

border-radius:10px; /* 所有角都使用半径为10px的圆角 */

border-radius: 5px 4px 3px 2px; /* 四个半径值分别是左上角、右上角、右下角和左下角,顺时针 */

不要以为border-radius的值只能用px单位,你还可以用百分比或者em,但兼容性目前还不太好。

实心上半圆:

方法:把高度(height)设为宽度(width)的一半,并且只设置左上角和右上角的半径与元素的高度一致(大于也是可以的)。

css;">div{   
  
  /*是width的一半*/     
     
  background:#9da;     
  border-radius:50px 50px 0 0;/*半径至少设置为height的值*/     
  }  

实心圆:

方法:把宽度(width)与高度(height)值设置为一致(也就是正方形),并且四个圆角值都设置为它们值的一半。

如下代码:

div{   
  /*与width设置一致*/    
     
   background:#9da;   
   border-radius:50px;/*四个圆角值都设置为宽度或高度值的一半*/    
  } 

完整代码

  
  
  
  
border-radius</www.dztcsd.com/title>  
<style type="text/css">  
div.circle{   
    /*与width设置一致*/   
       
    background:#9da;   
    border-radius:50px;/*四个圆角值都设置为宽度或高度值的一半*/   
    }   
/*任务部分*/      
div.semi-circle{    
       
       
    background:#9da;   
    border-radius:?;   
    }   
      
</style>  
</head>  
<body>  
<div class="circle">  
</div>  
<br/>  
<!--任务部分-->  
<div class="semi-circle">  
</div>  
  
</body>  
</html></pre>                            </div>
        </div>
            </section>
    <section class="wrap-box">
        <div class="g-tit">
            <h2>相关文章</h2>
        </div>
        <ul class="s-list nobord notop">
                            <li>
                    <a href="/art-424663.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">以闪亮之名店长体验流霞季怎么玩 缘溪临霞套装活动介绍</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773ba51f3b2c1.jpeg" alt="以闪亮之名店长体验流霞季怎么玩 缘溪临霞套装活动介绍" />
                        </div>
                    </a>
                </li>
                            <li>
                    <a href="/art-424664.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">未定事件簿旧梦新生左然篇怎么玩 旧梦新生左然篇活动介绍</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773ba526948a1.jpeg" alt="未定事件簿旧梦新生左然篇怎么玩 旧梦新生左然篇活动介绍" />
                        </div>
                    </a>
                </li>
                            <li>
                    <a href="/art-424662.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">未定事件簿左然破浪远行怎么样</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773b29eb3f551.jpeg" alt="未定事件簿左然破浪远行怎么样" />
                        </div>
                    </a>
                </li>
                            <li>
                    <a href="/art-424661.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">桃源深处有人家行医问诊怎么玩</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773b29de06411.jpeg" alt="桃源深处有人家行医问诊怎么玩" />
                        </div>
                    </a>
                </li>
                            <li>
                    <a href="/art-424660.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">恋与制作人跨年福利有哪些 恋与制作人跨年福利内容介绍</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773ac764837c1.jpeg" alt="恋与制作人跨年福利有哪些 恋与制作人跨年福利内容介绍" />
                        </div>
                    </a>
                </li>
                            <li>
                    <a href="/art-424659.htm" class="s-card">
                        <div class="s-card-l">
                            <p class="tit">阴阳师协同对弈大乱斗怎么玩 阴阳师协同对弈大乱斗活动介绍</p>
                            <div class="info">
                                <span class="person">游戏攻略</span>
                                <span class="time">2024-12-31</span>
                            </div>
                        </div>
                        <div class="s-card-pic">
                            <img src="/images/lazy.gif" data-src="/uploads/20241231/logo_6773ac754a7ec1.jpeg" alt="阴阳师协同对弈大乱斗怎么玩 阴阳师协同对弈大乱斗活动介绍" />
                        </div>
                    </a>
                </li>
                    </ul>
    </section>
    <section class="wrap-box">
        <div class="g-tit">
            <h2>精彩推荐</h2>
        </div>
        <ul class="card-box">
                            <li class="card3">
                    <a href="/app/102607.htm" target="_self" class="figure">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e884571f1.png" alt="三国战纪2果盘渠道服 安卓版v2.41.0.0" />
                        </div>
                        <p class="figure-head">三国战纪2果盘渠道服 安卓版v2.41.0.0</p>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card3">
                    <a href="/app/102601.htm" target="_self" class="figure">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e76652f11.png" alt="swammys进击的巨人手游 最新版v1.0" />
                        </div>
                        <p class="figure-head">swammys进击的巨人手游 最新版v1.0</p>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card3">
                    <a href="/app/102582.htm" target="_self" class="figure">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e352defa1.png" alt="城市英雄超级忍者 最新版v1.5" />
                        </div>
                        <p class="figure-head">城市英雄超级忍者 最新版v1.5</p>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card3">
                    <a href="/app/102543.htm" target="_self" class="figure">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2dcba328b1.png" alt="黑神话悟空之再战天庭无敌版 v0.11" />
                        </div>
                        <p class="figure-head">黑神话悟空之再战天庭无敌版 v0.11</p>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                    </ul>
        <ul class="card-box-b">
                            <li class="card10">
                    <a href="/app/102603.htm" target="_self" class="figure2">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e789d3961.jpg" alt="米加小镇世界龙年无广告版 安卓版v1.81" />
                        </div>
                        <div class="figure-cont">
                            <p class="figure-head">米加小镇世界龙年无广告版 安卓版v1.81</p>
                            <div class="figure-desc">
                                <span>模拟经营</span>
                                <span>米加小镇世界龙年无广告版 安卓版v1.81</span>
                            </div>
                            <div class="figure-desc">
                                <p>米加小镇世界龙年无广告是一款模拟类手游,不少的玩家可能都玩过</p>
                            </div>
                        </div>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card10">
                    <a href="/app/102597.htm" target="_self" class="figure2">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e64beb681.png" alt="部落冲突互通服 安卓版v17.100.1" />
                        </div>
                        <div class="figure-cont">
                            <p class="figure-head">部落冲突互通服 安卓版v17.100.1</p>
                            <div class="figure-desc">
                                <span>模拟经营</span>
                                <span>部落冲突互通服 安卓版v17.100.1</span>
                            </div>
                            <div class="figure-desc">
                                <p>部落冲突互通服是全球风靡的战争策略手游,连接安卓和iOS服务</p>
                            </div>
                        </div>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card10">
                    <a href="/app/102591.htm" target="_self" class="figure2">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e548c3bd1.png" alt="我的世界恶魔模组资源包 (EDU HELL)最新版vDEATH" />
                        </div>
                        <div class="figure-cont">
                            <p class="figure-head">我的世界恶魔模组资源包 (EDU HELL)最新版vDEATH</p>
                            <div class="figure-desc">
                                <span>模拟经营</span>
                                <span>我的世界恶魔模组资源包 (EDU HELL)最新版vDEATH</span>
                            </div>
                            <div class="figure-desc">
                                <p>我的世界恶魔版是一款像素风格的开放世界沙盒游戏,游戏中你可以</p>
                            </div>
                        </div>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card10">
                    <a href="/app/102588.htm" target="_self" class="figure2">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2e4ca40381.png" alt="艺术大亨天天拍卖变富翁 最新安卓版v1.31.0" />
                        </div>
                        <div class="figure-cont">
                            <p class="figure-head">艺术大亨天天拍卖变富翁 最新安卓版v1.31.0</p>
                            <div class="figure-desc">
                                <span>模拟经营</span>
                                <span>艺术大亨天天拍卖变富翁 最新安卓版v1.31.0</span>
                            </div>
                            <div class="figure-desc">
                                <p>艺术大亨天天拍卖变富翁是一款非常好玩的模拟经营类手游,在游戏</p>
                            </div>
                        </div>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                            <li class="card10">
                    <a href="/app/102560.htm" target="_self" class="figure2">
                        <div class="figure-box">
                            <img src="/images/lazy.gif" data-src="https://img.111cn.net/uploads/20250106/logo_677b2deed289f1.png" alt="大型巴士司机游戏 安卓版v2.1.0" />
                        </div>
                        <div class="figure-cont">
                            <p class="figure-head">大型巴士司机游戏 安卓版v2.1.0</p>
                            <div class="figure-desc">
                                <span>模拟经营</span>
                                <span>大型巴士司机游戏 安卓版v2.1.0</span>
                            </div>
                            <div class="figure-desc">
                                <p>大型巴士司机是一款模拟驾驶类游戏,玩家们将在游戏中化身为大巴</p>
                            </div>
                        </div>
                        <span class="figure-btn">下载</span>
                    </a>
                </li>
                    </ul>
    </section>
    <footer class="foot">
    <a href="/" class="logo-icon">
        <img src="/mobile/images/logo2.png" alt="一聚教程网">
    </a>
    <p>Copyright © 2010-2022</p>
    <p>111cn.net All Rights Reserved</p>

</footer>
<script>
    var advData = {"img_fixed_pc_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e9729f58.jpg","img_fixed_mob_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e8793225.jpg","url_adv":"http:\/\/shop.hushen.cn\/shop\/c\/baojianpin.html","str_adv":"\u864e\u795e\u5546\u57ce\uff1a\u5173\u7231\u7537\u6027\uff0c\u66f4\u61c2\u7537\u4eba\u3002\u89e3\u51b3\u5927\u4f17\u7684\u7537\u8a00\u4e4b\u9690","img_popup_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e748238d.png","pc_show_img":"2","pc_show_popup":"2","pc_show_video":"2","mob_show_img":"2","mob_show_popup":"2","mob_show_video":"2","close_adv":"https:\/\/img.111cn.net\/uploads\/20240508\/663b20650801e.png","video_adv":"\/pc\/images\/pc-adv.mp4"};
</script>
<script src="/jspc/funcmob.js" type="text/javascript"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DSRRGRV1TL"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-DSRRGRV1TL');
</script>    <div class="back-top" style="display: block;">
        <span class="icon-box">
            <svg class="icon" viewBox="0 0 1024 1024">
                <path d="M213.333333 640h170.666667v256h256v-256h170.666667l-298.666667-341.333333zM170.666667 128h682.666666v85.333333H170.666667z" fill="#0374f3"></path>
            </svg>
        </span>
    </div>
</div>
<script src="/js/stat.js"></script>
</body>
</html>