html+css实现三角形

介绍

通过 html + css , 实现不同方向的三角形

效果图

在这里插入图片描述

需求背景

现在经常会发现很多网页上的导航, 分类页等页面, 都会使用一个三角符号去指向内容,效果简洁美观 ; 并且现在很多的前端面试中, 也会问到怎么在网页当中实现一个三角的符号,所以自己做了, 各个方向的三角符号, 记得收藏哦~

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小三角</title>
    <style>
        .index {
            height: 200px;
            width: 500px;
            margin: 50px auto;
            background-color: #ddd;
        }
        .up{
        width:0px;
        height:0px;
        border-bottom:30px solid #fff;
        border-left:15px solid transparent;
        border-right:15px solid transparent;
        margin:10px auto;
        }
        .down{
        width:0px;
        height:0px;
        border-top:30px solid #fff;
        border-left:15px solid transparent;
        border-right:15px solid transparent;
        margin:10px auto;
        }
        .left{
        width:0px;
        height:0px;
        border-right:30px solid #fff;
        border-top:15px solid transparent;
        border-bottom:15px solid transparent;
        margin:10px auto;
        }
        .right{
        width:0px;
        height:0px;
        border-left:30px solid #fff;
        border-top:15px solid transparent;
        border-bottom:15px solid transparent;
        margin:10px auto;
        }
        </style>
</head>
<body>
    <div class="index">
        <!-- 正三角 -->
        <div class="up"></div>
        <!-- 倒三角 -->
        <div class="down"></div>
        <!-- 左边三角 -->
        <div class="left"></div>
        <!-- 右边三角 -->
        <div class="right"></div>
    </div>
</body>
</html>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值