zoukankan      html  css  js  c++  java
  • CSS 三角形

    用块边框实现css三角形,首先必须是个块级元素,可以本身是块,也可以display块。然后来点启发

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
        #box{
            width: 0;
            height: 0;
            border-width: 50px;
            border-style: solid;
            border-color: red green yellow blue;
        }
        </style>
    </head>
    <body>
    
    <div id="box"></div>
    
    </body>
    </html>

    效果:

    然后让下边框宽度为0:

    <style type="text/css">
        #box{
            width: 0;
            height: 0;
            border-width: 50px 50px 0;
            border-style: solid;
            border-color: red green yellow blue;
        }
    </style>

    效果:

    最后让左右颜色透明,大功告成!其他方向也一样。

    <style type="text/css">
        #box{
            width: 0;
            height: 0;
            border-width: 50px 50px 0;
            border-style: solid;
            border-color: red transparent;
        }
    </style>

    效果:

  • 相关阅读:
    习题2-7
    习题2-6
    习题2-5
    习题2-4
    习题2-3
    作业二 分支循环结构
    2- 8
    实验三-计算圆柱体积
    实验三-计算n个圆柱体体积
    实验3-计算圆面积
  • 原文地址:https://www.cnblogs.com/kiscall/p/5004540.html
Copyright © 2011-2022 走看看