• sass方式实现颜色平铺(红色--->紫色)


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <link rel="stylesheet" href="style/demo.css">
    </head>
    <body>
    <div class="test">
    <div class="color1"></div>
    <div class="color2"></div>
    <div class="color3"></div>
    <div class="color4"></div>
    <div class="color5"></div>
    <div class="color6"></div>
    <div class="color7"></div>
    </div>
    <div style="clear:both;"></div>
    <div class="test2"></div>
    </body>
    </html>

    @charset "UTF-8";
    $list: red orange yellow green grey blue purple;
    //$len: length($list);//自动获取长度
    $ percentage(1/7);
    @for $i from 1 through 7 {
    .test .color#{$i} {
    $width;
    background-color: nth($list, $i);
    height: 10px;
    float: left;
    }
    }

    .test {
    100%;
    }
    //使用这种方法(background-image: linear-gradient)也可以实现各种颜色的布局
    .test2 {
    // 100%;
    //background-image: linear-gradient(to right, red 0%, red $width,orange $width, orange $width * 2);
    }

    注意:sass里边写的div个数应该与html里的布局一致,否则是识别不到的。
    没有人能一路单纯到底,但是要记住,别忘了最初的自己!
  • 相关阅读:
    vue--一些预设属性
    vue--vux框架的使用
    vue--vConsole
    vue--音乐播放器
    vue--使用vue-cli构建项目
    vue--实例化对象
    vue--数据显示模版上
    CSS--交互效果
    Git SSH公钥配置
    gradle配置国内镜像
  • 原文地址:https://www.cnblogs.com/LindaBlog/p/9468730.html
Copyright © 2020-2023  润新知