zoukankan      html  css  js  c++  java
  • 使用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会更简单。

  • 相关阅读:
    C# html转mht
    前端插件
    通过GhostDoc实现自定义方法概要(summary)
    使用word模板生成pdf文件
    js 二维码
    POST 请求静态文件 响应405
    Notepad++ 两个格式化插件
    朴素的标题:MVC中权限管理实践
    对于api安全性的思考
    RSA私钥加密公钥解密、各种密钥格式转换
  • 原文地址:https://www.cnblogs.com/lingdublog/p/6510550.html
Copyright © 2011-2022 走看看