欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

css柵格系統(tǒng)在項目中靈活運用的示例分析

這篇文章主要介紹了css柵格系統(tǒng)在項目中靈活運用的示例分析,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

站在用戶的角度思考問題,與客戶深入溝通,找到襄州網(wǎng)站設(shè)計與襄州網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站設(shè)計制作、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名與空間、虛擬主機、企業(yè)郵箱。業(yè)務(wù)覆蓋襄州地區(qū)。

前言

css柵格通常捆綁在各種框架中,但有時你需要自己去定制一個css柵格來滿足實際的業(yè)務(wù)需要,本文聊聊css柵格系統(tǒng)在項目中的靈活運用。

需求

UI設(shè)計了如下布局,其中左上角橙色部分是固定的,藍色部分是動態(tài)渲染的,從前往后依次展示,有一個就顯示一塊,有二個就顯示二塊,依次類推。如果數(shù)據(jù)多于6個,那么多余的數(shù)據(jù),依次再在下方四列的地方進行展示。

css柵格系統(tǒng)在項目中靈活運用的示例分析

分析

從圖中可以看到,柵格分兩種,一種是3列的柵格,一種是4列的柵格。當后端接口返回數(shù)據(jù)后,js需要進行判斷:當數(shù)據(jù)大于6個時,前6個放在數(shù)組A中,數(shù)組A中的數(shù)據(jù)展示在3列的柵格中,多余部分放在數(shù)組B中,數(shù)組B中的數(shù)據(jù)展示在4列的柵格中。

html部分

<div id="app">
  <div class="grid-container">
    <div style="width: 25%; height: 220px; float: left; background-color: #FF6600; "></div>
    <div class="row" style="width: 75%; float: right;">
      <div class="col-3" v-for="(item, index) in groupListCol3" :key="index">
        <div class="groups-cell">{{item.name}}</div>
      </div>
    </div>
    <div class="row" style="width: 100%;">
      <div class="col-4" v-for="(item, index) in groupListCol4" :key="index">
        <div class="groups-cell">{{item.name}}</div>
      </div>
    </div>
  </div>
</div>

css部分

.grid-container {
      width: 100%;
    }
    .grid-container *{
      box-sizing: border-box;
    }

    .grid-container .row:before,
    .grid-container .row:after {
      content: "";
      display: table;
      clear: both;
    }

    .grid-container [class*='col-'] {
      float: left;
      min-height: 1px;
      /*-- gutter --*/
      padding: 0 0 20px 20px;
    }
    .grid-container .col-3{
      width: 33.33%;
      height: 120px;
    }
    .grid-container .groups-cell {
      background-color: #66d3ff;
      height: 100px;
    }
    .grid-container .col-4 {
      width: 25%;
      height: 120px;
    }
    .grid-container .col-4:nth-child(4n+1) {
      padding: 0 0px 20px 0px;
    }

注意:在4列的柵格中,每行的第一個單元格不需要padding-left,所以,最后,還得設(shè)置.col-4:nth-child(4n+1)的值。

js部分

<script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      groupListCol3: [],
      groupListCol4: []
    },
    created () {
      let list = [
        {name: 'A'},
        {name: 'B'},
        {name: 'C'},
        {name: 'D'},
        {name: 'E'},
        {name: 'F'},
        {name: 'G'},
        {name: 'H'},
        {name: 'I'},
        {name: 'J'},
        {name: 'K'},
        {name: 'L'}
      ]
      if (list.length > 6) {
        this.groupListCol3 = list.slice(0, 6)
        this.groupListCol4 = list.slice(6)
      } else {
        this.groupListCol3 = list
      }
    }
  })
</script>

感謝你能夠認真閱讀完這篇文章,希望小編分享的“css柵格系統(tǒng)在項目中靈活運用的示例分析”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!

本文題目:css柵格系統(tǒng)在項目中靈活運用的示例分析
文章URL:http://chinadenli.net/article36/ggjhsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序關(guān)鍵詞優(yōu)化網(wǎng)站建設(shè)域名注冊品牌網(wǎng)站設(shè)計面包屑導航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)