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)
      }
    }
  • 相关阅读:
    判断奇偶
    数据库中去重时:建议使用group by
    将博客搬至CSDN
    FileZilla
    Windows通过VNC连接并显示Linux桌面(Ubuntu16.04)
    springMVC 中参数绑定
    get和post的区别主要有以下几方面
    Get、Post、Put与Delete的区别
    HTTP请求地址映射
    Spring MVC 框架
  • 原文地址:https://www.cnblogs.com/ar13/p/7966243.html
Copyright © 2011-2022 走看看