css三角形做法(上手快)

四个三角形

效果:

效果图

样式:

 .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            border-top: 20px solid pink;
            border-right: 20px solid red;
            border-left: 20px solid blue;
            border-bottom: 20px solid orange;
        }

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            border-top: 20px solid pink;
            border-right: 20px solid red;
            border-left: 20px solid blue;
            border-bottom: 20px solid orange;
        }
    </style>
</head>
<body>
    <div class="angle"></div>
</body>
</html>

左侧三角形

效果:

左侧三角形图片

样式:

 .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 左侧设置边框样式 */
            border-left: 20px solid red;
        }

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 左侧设置边框样式 */
            border-left: 20px solid red;
        }
    </style>
</head>
<body>
    <div class="angle"></div>
</body>
</html>

右侧三角形

效果:

右侧三角形

样式:

.angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 右侧设置边框样式 */
            border-right: 20px solid blue;
        }

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 右侧设置边框样式 */
            border-right: 20px solid blue;
        }
    </style>
</head>
<body>
    <div class="angle"></div>
</body>
</html>

上边三角形

效果:

上边三角形

样式:

 .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 上边设置边框样式 */
            border-top: 20px solid orange;
        }

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 上边设置边框样式 */
            border-top: 20px solid orange;
        }
    </style>
</head>
<body>
    <div class="angle"></div>
</body>
</html>

下边三角形

效果:

下边三角形

样式:

.angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 下边设置边框样式 */
            border-bottom: 20px solid pink;
        }

代码:

在这里插入代码片<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .angle{
            margin: 100px auto;
            width: 0;
            height: 0;
            /* 四个边框设置为透明 */
            border: 20px solid transparent;
            /* 下边设置边框样式 */
            border-bottom: 20px solid pink;
        }
    </style>
</head>
<body>
    <div class="angle"></div>
</body>
</html>

注意:

  1. width:0 宽度为0
  2. height:0 高度为0
  3. 对边框设置样式
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值