• 使用CSS3制作网站常用的小三角形


    现在在前端开发中,经常会看到一些小三角形,如一些导航的下拉菜单,还有一些聊天信息的气泡模式,很多时候我们都是通过切图片的方法来制作,今天零度给大家分享一个完全通过css3实现的小三角效果。

    先上html代码:

    <div class="arrow-up">
         <!--向上的三角-->
    </div>
    <div class="arrow-right">
        <!--向右的三角-->
    </div>
    <div class="arrow-down">
        <!--向下的三角-->
    </div>
    <div class="arrow-left">
        <!--向左的三角-->
    </div>

    我使用了四个div分别展示上下左右四个方向的箭头,下面是css代码:

    /*箭头向上*/
    .arrow-up {
        0; 
        height:0; 
        border-left:30px solid transparent;
        border-right:30px solid transparent;
        border-bottom:30px solid #f00;
    }
    
    /*箭头向右*/
    .arrow-right {
        0; 
        height:0; 
        border-top:20px solid transparent;
        border-bottom: 20px solid transparent;
        border-left: 20px solid green;
    }
        
     /*箭头向下*/
    .arrow-down {
        0; 
        height:0; 
        border-left:40px solid transparent;
        border-right:40px solid transparent;
        border-top:40px solid #ccc;
    }
        
     /*箭头向左*/
    .arrow-left {
        0; 
        height:0; 
        border-top:30px solid transparent;
        border-bottom:30px solid transparent; 
        border-right:30px solid #00f; 
    }

    这样出来的效果就是这样:

    颜色和大小当然可以随意控制,这样以后我们就不需要切图了,直接使用css会更简单。

  • 相关阅读:
    ie兼容,手机端兼容问题
    JS-cookie和正则表达式
    第六节蓝桥杯 方格填数
    最长公共子串长度
    上台阶问题
    各种好东西
    Painting the balls (dp优化)
    Nobita's New Filesystem (bitset)
    恐狼后卫 (区间dp)
    CF701F String set queries (分块思想+暴力)
  • 原文地址:https://www.cnblogs.com/lingdublog/p/6510550.html
Copyright © 2020-2023  润新知