zoukankan      html  css  js  c++  java
  • css实现栅格的方法

    1. 方法一

    1.1. 效果

     

    2. 方法二

    2.1. 效果

     

    3. 代码

    3.1. Html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    
        <link rel="stylesheet/less" type="text/css" href="test.less"/>
        <script src="lib/less-1.7.1.min.js" type="text/javascript"></script>
    
    </head>
    <body>
    <h2>方法一</h2>
    
    <div class="method-01">
        <div class="row">
            <div class="cell cell-01"></div>
            <div class="cell cell-02"></div>
        </div>
        <div class="row">
            <div class="cell cell-01"></div>
            <div class="cell cell-02"></div>
        </div>
    </div>
    
    <h2>方法二</h2>
    
    <div class="method-02">
        <div class="row">
            <div class="cell cell-01"></div>
            <div class="cell cell-02"></div>
        </div>
        <div class="row">
            <div class="cell cell-01"></div>
            <div class="cell cell-02"></div>
        </div>
    </div>
    </body>
    </html>
    

      

    3.2. Less

    body {
      margin: 0;
    }
    
    .row {
      background: #000;
      margin-bottom: 10px;
    
      .cell {
        &.cell-01 {
           100px;
          height: 200px;
          background: #FF0;
        }
    
        &.cell-02 {
           200px;
          height: 300px;
          background: #F0F
        }
      }
    }
    
    .method-01 {
      .row {
        .cell {
          display: inline-block;
          vertical-align: top;
        }
      }
    }
    
    .method-02 {
      .row {
         100%;
        display: inline-block;
    
        .cell {
          float: left;
        }
      }
    }
    

      

  • 相关阅读:
    js实现element中可清空的输入框(1)
    vue中v-model的学习
    Oracle触发器和MySQL触发器的简单应用
    Java中的多线程你只要看这一篇就够了()
    HTML 随笔记之 刷新页面
    HTML CSS 随笔记之 cursor
    float到底是干什么的?
    Spring Boot 事物的快速应用
    java web 中文乱码
    LVM 创建实例
  • 原文地址:https://www.cnblogs.com/ningkyolei/p/5193478.html
Copyright © 2011-2022 走看看