zoukankan      html  css  js  c++  java
  • [css] 利用border制作三角型

    1、利用border边框的特性,使加boder边框的元素宽高都为0,因为外边设置太宽里面太窄,所以呈现出三角形状。

    <html>
    <head>
    <style>
            .square{
                width: 0px;
                height: 0px;
                border: 50px solid transparent;
                border-color: red blue pink yellow;
            }
     </style>
    </head>
    <body>
        <div class="square"></div>
    </body>
    </html>

    2、如果只给上面的边框设置颜色,那么就会呈现出三角形状
    <style>
        {
                border: 50px solid transparent;
                border-top-color: red;
            }
     </style>
     3、也可以利用定位白色三角覆盖到红色三角上边制作出三角箭头
    <html>
    <head>
        <style>
            .box{
                position: relative;
            }
            .square{
                margin-top: 100px;
                width: 0;
                height: 0;
                border: 50px solid transparent;
                border-top-color: red;
            }
            .square::after{
                content: '';
                display: block;
                width: 0;
                height: 0;
                border: 50px solid transparent;
                border-top-color: white;
                position: absolute;
                left:0;
                top: -10px;
            }
        </style>
    </head>
    <body>
        <div class="box">
        <div class="square"></div>
        </div>
    </body>
    </html>
  • 相关阅读:
    “访问”美术馆
    加分二叉树
    有线电视网
    二叉苹果树
    鬼子进村
    遍历问题
    最大子树和
    FBI树
    求前序遍历
    JS如何实现点击页面内任意的链接均加参数跳转?
  • 原文地址:https://www.cnblogs.com/lv77/p/13855613.html
Copyright © 2011-2022 走看看