CSS图形——实现圆角

 

css实现圆角

css2.1给元素添加圆角是一件很麻烦的事,老办法是用背景图片实现,制作比较麻烦。css3,border-radius的属性,使圆角属性得到完美的解决。

语法

border-radius:长度值;

说明:

长度值可以是px、百分比、em等

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>圆角实现</title>
    <style type="text/css">
        div{
            width: 100px;
            height: 50px;
            border-radius: 10px;
            background-color: yellow;
        }
    </style>
</head>
<body>

    <div></div>
    
</body>
</html>

设置border-radius:10px;设置的四个圆角半径都是10px

 border-radius属性值有四个写法(同margin、padding相似)

(1)border-radius:一个值;

        结果如上图

(2)border-radius:两个值;

       例如:border-radius:10px 20px;表示左上角、右下角为10px,右上角、左下角为20px;

     结果

   

(3)border-radius:设置三个值;

    例如:border-radius:10px 20px 30px;表示左上角、右上角和左下角、左下角的圆角半径依次是10px、20px、30px

   结果

 

 

 

(4)border-radius:设置四个值

  例如:border-radius:10px 20px 30px 40px;表示左上角、右上角、右下角和左下角的圆角半径依次是10px 20px 30px 40px

 结果

 

 实现下图效果:

代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>圆角实现</title>
    <style type="text/css">
        div{
            width: 50px;
            line-height: 50px;
            border-radius:80% 90% 100% 20%;
            background-color: black;
            color: white;
            text-align: center;
            font-size: 30px;
        }
    </style>
</head>
<body>

    <div>6</div>
    
</body>
</html>

 

转载于:https://www.cnblogs.com/masanhe/p/8358817.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值