美文网首页
使用CSS画一个三角形

使用CSS画一个三角形

作者: 小李不小 | 来源:发表于2021-08-17 10:02 被阅读0次

代码+效果图

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        /* css3绘制三角形 */
        .triangle{
            width: 0px;                           /*设置宽高为0,所以div的内容为空,从才能形成三角形尖角*/
            height: 0px;
            border-bottom: 200px solid #00a3af;
            border-left: 200px solid transparent;    /*transparent 表示透明*/
            border-right: 200px solid transparent;
        }
    </style>
</head>
<body>
    <div class="triangle"></div>
</body>
</html>
image.png

实现步骤 - 还是不理解的小伙伴可以看下面

1. 首先画一个 四边形
    <div class="triangle"></div>
.triangle{
   width: 0px;
   height: 0px;
   border-top: 200px solid #00a497;
   border-bottom: 200px solid #cc7eb1;
   border-left: 200px solid #165e83;
   border-right: 200px solid #c85179;
}


image.png
2. 去掉border-top,三角顶部就不见了
    <div class="triangle"></div>
.triangle{
    width: 0px;
    height: 0px;
    border-bottom: 200px solid #cc7eb1;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
}
image.png
2. 最后发现,只将border-bottom设置颜色,左右边框透明,既可得到三角形
    <div class="triangle"></div>
.triangle{
    width: 0px;
    height: 0px;
    border-bottom: 200px solid #cc7eb1;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
}

//transparent 设置为透明的意思


相关文章

  • 如何用css画三角形&太极

    一、如何用css画一个三角形 搜索学习资源:Google >>css tricks shape >> 画一个如下图...

  • 关于CSS画三角形的那些事儿

    用CSS画一个三角形,是不难的问题,但我却掌握的不够熟练,例如当要求为画一个直角三角形或者等腰三角形,我就有点反应...

  • 20170307 第十三课时 盒模型之border设置

    作业:用CSS控制DIV的边框画一个三角形 盒模型之border讲解 di...

  • 记一次面试

    1.css垂直水平居中方法有哪些2.css三栏布局3.css写一个三角形4.css画一条0.5px的线5.cons...

  • css 实现三角形箭头

    插入DOM 使用伪类 参考:用纯CSS实现的箭头CSS画三角形原理css整理 -- 右箭头,上下箭头,三角形 这个...

  • CSS画一个三角形

    CSS画一个三角形出来 具体原理实现 一个加了边框的DIV DIV边框的划分规则1.CSS中的边框划分如图所示,只...

  • css 如何写排序三角形箭头

    如何使用css编写三角形:/* css3三角形(向上 ▲) /div.arrow-up {width:0px;he...

  • 使用CSS画一个三角形

    代码+效果图 实现步骤 - 还是不理解的小伙伴可以看下面 1. 首先画一个 四边形 2. 去掉border-top...

  • canvas基本操作

    画一条直线 画一个矩形 画一个三角形 画一个圆

  • vue项目中使用三角形怎么办

    解决办法 美工同事切三角形图片icon 自己使用ps或者其他工具画出三角形并导出使用 纯css写一个三角形(类似A...

网友评论

      本文标题:使用CSS画一个三角形

      本文链接:https://www.haomeiwen.com/subject/eqoxbltx.html