zoukankan      html  css  js  c++  java
  • 网栅格布局

    其中最主要运用到了 calc 这个 css3 功能

         calc(50% - 20px);
        // 在宽度50%的情况下,减去20px的值
    

    html 代码

    <!-- col-md-4 -->
    <!-- 适用于应屏幕宽度大于 768px 的场景 -->
        <div class="row">
            <div class="col-md-4 col col-sm-6"></div>
            <div class="col-md-4 col col-sm-6"></div>
            <div class="col-md-4 col col-sm-12"></div>
        </div>
        <div class="row">
            <div class="col-md-3 col col-sm-3"></div>
            <div class="col-md-6 col col-sm-6"></div>
            <div class="col-md-3 col col-sm-3"></div>
        </div>
        <div class="row">
            <div class="col-md-1 col-sm-2 col "></div>
            <div class="col-md-1 col-sm-2 col"></div>
            <div class="col-md-2 col-sm-8 col"></div>
            <div class="col-md-2 col-sm-3 col"></div>
            <div class="col-md-6 col-sm-3 col"></div>
        </div>    
    

    css 代码

        body {
      margin: 0;
      padding: 0;
      height: 100%;
    }
    .row {
      clear: both;
      height: auto;
    }
    
    .row .col {
      box-sizing: border-box;
      border: 1px solid #999999;
      background-color: #EEEEEE;
      height: 50px;
      float: left;
      margin: 10px 10px 10px 10px;
    }
    
    /* 最小宽度769px */
    @media only screen and (min- 769px){
      .row .col-md-6 {
         calc(50% - 20px);
      }
      .row .col-md-4 {
         calc( 33.3% - 20px)
      }
      .row .col-md-3 {
         calc(25% - 20px)
      }
      .row .col-md-2 {
         calc(16.7% - 20px)
      }
      .row .col-md-1 {
         calc(8.3% - 20px)
      }
    }
    
    /* 最大宽度 768px */
    @media only screen and (max- 768px){
      .row .col-sm-6 {
         calc(50% - 20px);
      }
      .row .col-sm-12 {
         calc( 100% - 20px)
      }
      .row .col-sm-8 {
         calc( 66.6% - 20px)
      }
      .row .col-sm-3 {
         calc(25% - 20px)
      }
      .row .col-sm-2 {
         calc(16.7% - 20px)
      }
      .row .col-sm-1 {
         calc(8.3% - 20px)
      }
    }
  • 相关阅读:
    nosql----redis持久化详解
    linux下发送邮件
    自动化运维工具----ansiable安装与配置
    nginx----统计网站访问量
    机试指南第二章-经典入门-排序例题自解
    机试指南第二章-经典入门-排序模板
    Theano入门
    OpenJudge 4120 硬币
    OpenJudge 1088 滑雪
    OpenJudge 4152 最佳加法表达式
  • 原文地址:https://www.cnblogs.com/ar13/p/7966243.html
Copyright © 2011-2022 走看看