zoukankan      html  css  js  c++  java
  • css条纹背景

    一、 水平条纹

    1. 两种颜色:

    html

    <div class="stripe"></div>

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: linear-gradient(#fb3 50%,#58a 50%);
      background-size: 100% 30px;
    }

    效果图

    2. 不等宽的条纹背景

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: linear-gradient(#fb3 40%,#58a 0);
      background-size: 100% 30px;
    }

    效果图

    3. 三列条纹背景
    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: linear-gradient(#fb3 33.3%,#58a 0,#58a 66.6%,deeppink 0);
      background-size: 100% 30px;
    }

    效果图

    二、垂直条纹

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: linear-gradient(to right,#fb3 33.3%,#58a 0,#58a 66.6%,deeppink 0);/*或者90deg*/
      background-size: 30px 100%;
    }

    效果图

    三、斜向条纹

    1. 45度角的斜向条纹

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: linear-gradient(45deg,#fb3 25%,#58a 0,
                                        #58a 50%,#fb3 0,
                                        #fb3 75%,#58a 0);
      background-size: 30px 30px;
    }

    效果图

    2. 其他角度的斜向条纹

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background: repeating-linear-gradient(120deg,#fb3 0,#fb3 15px,#58a 0,#58a 30px);
    }

    效果图

    说明:黄色条纹从0到15px线性渐变,蓝色条纹从15px到30px线性渐变。

    四、结合半透明实现同色系条纹

    css

    .stripe{
      width: 250px;
      height: 150px;
      margin: 50px;
      background-image: repeating-linear-gradient(30deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,.1) 15px,
                        transparent 0,transparent 30px);
      background: #58a;
    }

     参考网址https://www.w3cplus.com/css3/do-you-really-understand-css-linear-gradients.html

    https://www.w3cplus.com/content/css3-background-size

  • 相关阅读:
    Django 想要单独执行文件
    Django基础
    Bootstrap框架
    Font Awesome矢量图标框架
    js函数式编程——蹦床函数
    ie被hao.360劫持的解决方法
    函数式编程——惰性链
    你可能不知道的BFC在实际中的应用
    高度随宽度适应的响应式方案
    腾讯云播放器更新——TCplayer
  • 原文地址:https://www.cnblogs.com/Anita-meng/p/7867376.html
Copyright © 2011-2022 走看看