• Web前端基础精品入门(HTML+CSS+JavaScript+JS)[爱前端]听课笔记3:三角形的制作


    菜单中有的项目有夏季菜单,需要添加一个三角形,这个三角形是利用两个边框不同颜色产生的楔形制作的

    image

    设置盒子的高度和宽度均为0,边框合适的大小,透明颜色,对应边设置高度、颜色


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>三角形</title>
        <style type="text/css">
            .sjx{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-top: 10px solid red;
            }
        </style>
    
    </head>
    <body>
        <div class="sjx"></div>
    </body>
    </html>


    几个变形如下


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>三角形</title>
        <style type="text/css">
            .sjx{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-top: 10px solid red;
            }
            .sjx_left{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-left: 10px solid red;
            }
            .sjx_bottom{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-bottom: 10px solid red;
            }
            .sjx_right{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-right: 10px solid red;
            }
            .sjx_widen{
                0px;
                height:0px;
                border: 20px solid transparent;
                border-top: 10px solid red;
            }
            .sjx_height{
                0px;
                height:0px;
                border: 10px solid transparent;
                border-top: 20px solid red;
            }
        </style>
    
    </head>
    <body>
        上三角
        <div class="sjx"></div>
        左三角
        <div class="sjx_left"></div>
        底三角
        <div class="sjx_bottom"></div>
        右三角
        <div class="sjx_right"></div>
        上三角变宽
        <div class="sjx_widen"></div>
        上三角变高
        <div class="sjx_height"></div>
    </body>
    </html>

    最终的效果如下:

    image

  • 相关阅读:
    在蓝鲸标准运维上进行原子开发二
    python 使用eval报错NameError: name ‘null’ is not defined
    前端时间转换 2019-08-18T16:00:00.000Z 转换成格式2019-08-18
    python list排序
    Django 分页Paginator的简单用法
    蓝鲸ESB自定义组件的部署步骤
    Unity对象池的实现
    Unity3D UGUI实现Toast
    C#中扩展方法的使用
    Unity3D实现多语言切换
  • 原文地址:https://www.cnblogs.com/jilingxf/p/16209643.html
Copyright © 2020-2023  润新知