zoukankan      html  css  js  c++  java
  • 使用css完成引导用户按照流程完成任务的进度导航条

    首先先看设计稿

    clipboard.png

    图中的12345便是主角进度条。

    分析需求如下:
    线的长度不固定,适应移动端和pc端
    点平均地分布在一条线上
    点的个数不固定,可能会改变
    激活的点之间线的颜色是绿色的

    两种种方式 百分比宽度切分和flex布局

    clipboard.png

    贴上代码
    HTML

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <title>JS Bin</title>
    </head>
    <body>
      <div class="pub-wrap">
        <div class="pub-title" id="pubTitle">在群内累计布置3天作业,即可加入先锋教师!</div>
        <ul class="pub-process process-5" id="pubProcess">
          <li class="active"><span class="ball">1天</span></li>
          <li class="active"><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
        </ul>
      </div>
      
      <!-- flex版本 -->
      <div class="pub-wrap">
        <div class="pub-title" id="pubTitle">在群内累计布置3天作业,即可加入先锋教师!</div>
        <ul class="pub-process process-5 pub-process-flex" id="pubProcess">
          <li class="active"><span class="ball">1天</span></li>
          <li class="active"><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
          <li><span class="ball">1天</span></li>
        </ul>
      </div>
    </body>
    </html>
    

    css

    ul {
      margin:0;
      padding:0;
    }
    li {
      list-style: none;
    }
    
    .pub-wrap {
      position: relative;
      padding: 0 30px 10px;
      margin-top: 28px;
      border-radius: 6px;
      background-color: #edf2f2;
    }
    
    .pub-title {
      padding-top: 14px;
      margin-right: -20px;
      margin-left: -20px;
      font-size: 1.1875rem;
      text-align: center;
    }
    
    .pub-process {
      position: relative;
      height: 35px;
      margin-top: 28px;
      margin-left: 35px;
      font-size: 0;
      color: #fff;
    }
    
    .pub-process:after {
      position: absolute;
      top: 50%;
      left: 0;
      z-index: 1;
       99%;
      height: 4px;
      content: "";
      -webkit-transform: translate(0, -50%);
      transform: translate(0, -50%);
      background-color: #d9d9d9;
    }
    
    .pub-process li {
      position: relative;
      z-index: 5;
      display: inline-block;
       25%;
      height: 35px;
      font-size: .875rem;
    }
    
    .pub-process li:first-child {
       35px;
      margin-left: -35px;
    }
    
    .pub-process .ball {
      position: absolute;
      top: 0;
      right: 0;
      z-index: 7;
       35px;
      height: 35px;
      line-height: 35px;
      content: "";
      text-align: center;
      border-radius: 50%;
      background-color: #d9d9d9;
    }
    
    .pub-process .active .ball {
      background-color: #11c2c2;
    }
    
    .pub-process .active + .active:after {
      position: absolute;
      top: 50%;
      left: 0;
      z-index: 6;
       100%;
      height: 4px;
      content: "";
      -webkit-transform: translate(0, -50%);
      transform: translate(0, -50%);
      background-color: #11c2c2;
    }
    
    .process-3 li {
       50%;
    }
    
    .process-5 li {
       25%;
    }
    
    
    /* flex ver */
    .pub-process-flex {
      display: -webkit-box;
    }
    .pub-process-flex li {
      display: list-item;
      -webkit-box-flex: 1;
       auto;
    }
    .pub-process-flex li:first-child {
       35px;
      margin-left: -35px;
      -webkit-box-flex: 0;
    }

    实现效果如图

    clipboard.png

    使用百分比因为宽度是百分比设死的,这样在点的数量修改时,我们还是要改css,所以建议使用flex布局更完美。

    clipboard.png

  • 相关阅读:
    animation——鼠标放上图片旋转
    docker安装Redis并设置密码
    Docker安装MySQL详细教程(mysql是5.7版本,可以根据自己需要修改版本)
    Linux安装jdk(两种方式)
    Nginx http 反向代理高级应用
    jenkins 远程启动tomcat报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    从一个Git仓库转移到另外一个仓库
    使用Spring @DependsOn控制bean加载顺序
    Swagger2异常:Illegal DefaultValue null for parameter type integer java
    springboot的实体类Integer和int如何选择
  • 原文地址:https://www.cnblogs.com/10manongit/p/12882326.html
Copyright © 2011-2022 走看看