国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

這篇具有很好參考價(jià)值的文章主要介紹了grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

1、前言

?????????柵格布局或者說網(wǎng)格布局是很好用的東西,像一些商城類的排版就很適合用柵格布局,但是存在一定的兼容性問題,兼容性暫時(shí)還沒有研究,這邊學(xué)習(xí)總結(jié)是針對grid也就是柵格布局的使用的學(xué)習(xí)總結(jié),下面將介紹我認(rèn)為的常用的幾個屬性,如果想要更詳細(xì)的學(xué)習(xí),可以參考阮一峰老師的grid布局

2、使用

首先是html

<template>

<div class="grid-box">
  <div class="grid-item">1</div>
  <div class="grid-item">2</div>
  <div class="grid-item">3</div>
  <div class="grid-item">4</div>
  <div class="grid-item">5</div>
  <div class="grid-item">6</div>
  <div class="grid-item">7</div>
  <div class="grid-item">8</div>
  <div class="grid-item">9</div>
</div>

</template>

然后使用grid 布局列與行的列數(shù)行數(shù)都是根據(jù)需求來設(shè)置的,可以更改,更詳細(xì)的可以搜阮一峰老師的grid布局查看,在本文首頁有鏈接

.grid-box {
  // 柵格布局三行三列
  display: grid;
  // 3是多少行列 后面 100px是列寬,行的設(shè)置同理
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  .grid-item {
    font-size: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    background: rgb(239,52,41);
    &:nth-child(2){
      background: rgb(246,143,37);
    }
    &:nth-child(3){
      background: rgb(75,168,70);
    }
    &:nth-child(4){
      background: rgb(4,118,194);
    }
    &:nth-child(5){
      background: rgb(192,119,175);
    }
    &:nth-child(6){
      background: rgb(248,210,157);
    }
    &:nth-child(7){
      background: rgb(180,168,127);
    }
    &:nth-child(8){
      background: rgb(208,228,168);
    }
    &:nth-child(9){
      background: rgb(77,199,236);
    }
  }
}

救會出現(xiàn)這樣的效果了

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

如果想要好看點(diǎn)可以給父容器(.grid-box)加上一點(diǎn)內(nèi)邊距與陰影

padding: 10px;
box-shadow:  0 0 10px #999;

然后就得到了這樣效果

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

此時(shí)我么可能會有讓各個數(shù)字有間隙的需求,此時(shí)就可以用上下面兩個屬性了,也是在父容器設(shè)置的

// 行列間距
column-gap: 10px;
row-gap: 10px;

然后效果就是這樣的

?grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

? 此時(shí)我們克呢該有會有這樣的需求,就是按列排,而不是像上面按行排列,此時(shí)就需要使用到

 // 默認(rèn)是按先行后列的,現(xiàn)在也可以改為先列后行 默認(rèn)值是 row
 grid-auto-flow: column;

然后效果就是這樣的

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記以上內(nèi)容的完整代碼如下

<template>

<div class="grid-box">
  <div class="grid-item">1</div>
  <div class="grid-item">2</div>
  <div class="grid-item">3</div>
  <div class="grid-item">4</div>
  <div class="grid-item">5</div>
  <div class="grid-item">6</div>
  <div class="grid-item">7</div>
  <div class="grid-item">8</div>
  <div class="grid-item">9</div>
</div>

</template>

<script setup lang='ts'>
</script>
<style scoped lang="scss">
.grid-box {
  // 柵格布局三行三列
  display: grid;
  // 3是多少行列 后面 100px是列寬,行的設(shè)置同理
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  // 行列間距
  column-gap: 10px;
  row-gap: 10px;
  padding: 10px;
  box-shadow:  0 0 10px #999;
  // 默認(rèn)是按先行后列的,現(xiàn)在也可以改為先列后行
  grid-auto-flow: column;
  .grid-item {
    font-size: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    background: rgb(239,52,41);
    &:nth-child(2){
      background: rgb(246,143,37);
    }
    &:nth-child(3){
      background: rgb(75,168,70);
    }
    &:nth-child(4){
      background: rgb(4,118,194);
    }
    &:nth-child(5){
      background: rgb(192,119,175);
    }
    &:nth-child(6){
      background: rgb(248,210,157);
    }
    &:nth-child(7){
      background: rgb(180,168,127);
    }
    &:nth-child(8){
      background: rgb(208,228,168);
    }
    &:nth-child(9){
      background: rgb(77,199,236);
    }
  }
}
</style>

?假如每個單元格里面各自有內(nèi)容,可以是使用以下鏈各個屬性進(jìn)行布局,它們的值可以是

// 設(shè)置單元格的布局,但是這兩個屬性設(shè)置后會減該內(nèi)容壓縮,所以使用的時(shí)候要注意
// 他么可以取的值是 start | end | center | stretch 
justify-items: center;
align-items: center;

效果是這樣的

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記??

?還可以設(shè)置整體內(nèi)容的排版

// 設(shè)置容器內(nèi)整體內(nèi)容的排版
// 可取的值為 start | end | center | stretch | space-around | space-between | space-evenly;
justify-content: center;
align-content: center;

效果

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

?以上就是我認(rèn)為常用的容器的屬性,解釋一下容器與項(xiàng)目(容器內(nèi)的第一層子元素(項(xiàng)目里面的元素不是項(xiàng)目))在這里其實(shí)就是

.grid-box與.grid-item

3、項(xiàng)目屬性

?這里值寫四個屬性,其實(shí)不止,只不過作者是我認(rèn)為常用的屬性

grid-column-start屬性:左邊框所在的垂直網(wǎng)格線
grid-column-end屬性:右邊框所在的垂直網(wǎng)格線
grid-row-start屬性:上邊框所在的水平網(wǎng)格線
grid-row-end屬性:下邊框所在的水平網(wǎng)格線
// 設(shè)置單元格的內(nèi)容樣式
grid-column-start: 2;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 3;

效果

grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記

代碼:

<template>

<div class="grid-box">
  <div class="grid-item">1</div>
  <div class="grid-item">2</div>
  <div class="grid-item">3</div>
  <div class="grid-item">4</div>
  <div class="grid-item">5</div>
  <div class="grid-item">6</div>
  <div class="grid-item">7</div>
  <div class="grid-item">8</div>
  <div class="grid-item">9</div>
</div>

</template>

<script setup lang='ts'>
</script>
<style scoped lang="scss">
.grid-box {
  // 柵格布局三行三列
  height: 100%;
  display: grid;
  // 3是多少行列 后面 100px是列寬,行的設(shè)置同理
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  // 行列間距
  column-gap: 10px;
  row-gap: 10px;
  padding: 10px;
  box-shadow:  0 0 10px #999;
  // 默認(rèn)是按先行后列的,現(xiàn)在也可以改為先列后行()colunm)
  grid-auto-flow: row;
  // 設(shè)置單元格的布局,但是這兩個屬性設(shè)置后會減該內(nèi)容壓縮,所以使用的時(shí)候要注意
  // justify-items: center;
  // align-items: center;
  // 設(shè)置容器內(nèi)整體內(nèi)容的排版
  justify-content: center;
  align-content: center;
  .grid-item {
    font-size: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    background: rgb(239,52,41);
    &:nth-child(1) {
      // 設(shè)置單元格的內(nèi)容樣式
      grid-column-start: 2;
      grid-column-end: 4;
      grid-row-start: 1;
      grid-row-end: 3;
    }
    &:nth-child(2){
      background: rgb(246,143,37);
    }
    &:nth-child(3){
      background: rgb(75,168,70);
    }
    &:nth-child(4){
      background: rgb(4,118,194);
    }
    &:nth-child(5){
      background: rgb(192,119,175);
    }
    &:nth-child(6){
      background: rgb(248,210,157);
    }
    &:nth-child(7){
      background: rgb(180,168,127);
    }
    &:nth-child(8){
      background: rgb(208,228,168);
    }
    &:nth-child(9){
      background: rgb(77,199,236);
    }
  }
}
</style>

這是一個組件內(nèi)容,需要在app.vue中引入使用

以上就是我對grid學(xué)習(xí)的筆記總結(jié),歡迎批評指正,交流學(xué)習(xí)?文章來源地址http://www.zghlxwxcb.cn/news/detail-450230.html

到了這里,關(guān)于grid 柵格/網(wǎng)格布局學(xué)習(xí)筆記的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【CSS Grid網(wǎng)格布局】常用屬性,示例代碼解讀

    【CSS Grid網(wǎng)格布局】常用屬性,示例代碼解讀

    grid-template-columns/grid-template-rows:用于定義網(wǎng)格的列和行的大小和數(shù)量??梢灾付ň唧w的尺寸值(如px、em等),也可以使用fr單位表示剩余空間的比例分配。 grid-column-gap/grid-row-gap:用于定義網(wǎng)格的列間距和行間距??梢允褂镁唧w的尺寸值或百分比。 grid-template-areas:用于定義

    2024年02月12日
    瀏覽(16)
  • draggable + grid 拖拽插件 + 網(wǎng)格布局 動態(tài)生成首頁模版

    draggable + grid 拖拽插件 + 網(wǎng)格布局 動態(tài)生成首頁模版

    背景: ? ? ? ? 1、首頁模板由多個子組件組成,如圖表、新聞、公告、輪播圖等,一般都由前端引入子組件,寫在固定的位置上,最終形成一個固定的首頁模板; ? ? ? ? 2、像這樣直接在代碼中寫死的首頁沒有靈活性,不同用戶想展示出來的首頁模板千篇一律; ? ? ? ?

    2024年02月01日
    瀏覽(37)
  • Vue Grid Layout -? 適用Vue.js的柵格布局系統(tǒng)(保姆級使用教程)

    Vue Grid Layout -? 適用Vue.js的柵格布局系統(tǒng)(保姆級使用教程)

    官網(wǎng):Vue Grid Layout -? 適用Vue.js的柵格布局系統(tǒng) Gitee:https://gitee.com/wfeng0/vue2-grid-layout? 在官網(wǎng)的描述中,我們可以看出,該柵格布局具有以下特性: ?在具有 拖拽組成頁面、組件動態(tài)調(diào)整大小、邊緣碰撞監(jiān)測 的系統(tǒng)中,使用該布局無疑是最合適的。當(dāng)然,目前也有很多現(xiàn)成

    2023年04月16日
    瀏覽(33)
  • HarmonyOS應(yīng)用開發(fā)學(xué)習(xí)筆記 UI布局學(xué)習(xí) 柵格布局(GridRow/GridCol)

    HarmonyOS應(yīng)用開發(fā)學(xué)習(xí)筆記 UI布局學(xué)習(xí) 柵格布局(GridRow/GridCol)

    HarmonyOS應(yīng)用開發(fā)學(xué)習(xí)筆記 UI布局學(xué)習(xí) 相對布局 (RelativeContainer) 官方文檔:柵格布局(GridRow/GridCol) 通過設(shè)置GridRow的direction屬性來指定柵格子組件在柵格容器中的排列方向 代碼 描述 GridRowDirection.Row 從左往右排列 GridRowDirection.RowReverse 從右往左排列 左往右排列 子組件從右

    2024年02月03日
    瀏覽(24)
  • HTML5+CSS3學(xué)習(xí)筆記(九)前端頁面六大布局(文檔流布局、浮動布局、定位布局、表格布局、彈性布局、網(wǎng)格布局)

    HTML5+CSS3學(xué)習(xí)筆記(九)前端頁面六大布局(文檔流布局、浮動布局、定位布局、表格布局、彈性布局、網(wǎng)格布局)

    本系列更多文章,可以查看專欄 HTML+CSS學(xué)習(xí)筆記 塊級元素自上至下垂直排列,行內(nèi)元素自左至右水平排列 塊級元素獨(dú)占一行,行內(nèi)元素不會另起一行 默認(rèn)情況下,height和width決定內(nèi)容區(qū)的大?。粌?nèi)容區(qū)、內(nèi)邊距和邊框構(gòu)成可見區(qū)域的大小;外邊距決定元素的位置 更多內(nèi)容可

    2024年02月02日
    瀏覽(70)
  • 突破經(jīng)典網(wǎng)格特征?AutoFocusFormer: Image Segmentation off the Grid 論文閱讀筆記

    突破經(jīng)典網(wǎng)格特征?AutoFocusFormer: Image Segmentation off the Grid 論文閱讀筆記

    寫在前面 ??這一周趕上五一五天假了,朋友們出去 happy 了嗎?有沒有趕上人山人海的熱鬧?反正我只是在 5.1 那天出去走走,哈哈。 ??這是一篇關(guān)于實(shí)例分割的文章,所解決的問題在于實(shí)例分割中需要的小目標(biāo)像素分辨率太低,于是本文提出一種自適應(yīng)下采樣的方法來

    2024年02月06日
    瀏覽(52)
  • Flutter學(xué)習(xí)之旅 -網(wǎng)格布局

    Flutter學(xué)習(xí)之旅 -網(wǎng)格布局

    GridView列表三種形式 可以通過 GridView.count 實(shí)現(xiàn)網(wǎng)格布局 可以通過 GridView.extent 實(shí)現(xiàn)網(wǎng)格布局 可以通過 GridView.builder 實(shí)現(xiàn)網(wǎng)格布局 參數(shù):可以通過 SliveGridDelegateWithFiexdCrossAxisCount 來設(shè)置 GridView.count 參數(shù): 可以通過 SliveGridDelegateWithMaxCrossAxisExtent 來設(shè)置 GridView.extent 常用屬性 名稱

    2024年02月03日
    瀏覽(24)
  • 【Android筆記97】Android之RecyclerView使用GridLayoutManager網(wǎng)格布局

    這篇文章,主要介紹Android之RecyclerView使用GridLayoutManager網(wǎng)格布局。 目錄 一、GridLayoutManager網(wǎng)格布局 1.1、功能效果 1.2、案例代碼 (1)創(chuàng)建網(wǎng)格布局

    2024年02月15日
    瀏覽(22)
  • 鴻蒙開發(fā)-UI-布局-柵格布局

    鴻蒙開發(fā)-UI-布局-柵格布局

    鴻蒙開發(fā)-UI-布局 鴻蒙開發(fā)-UI-布局-線性布局 鴻蒙開發(fā)-UI-布局-層疊布局 鴻蒙開發(fā)-UI-布局-彈性布局 鴻蒙開發(fā)-UI-布局-相對布局 文章目錄 前言 一、基本概念 二、格柵容器組件 1.柵格系統(tǒng)斷點(diǎn) 2.布局的總列數(shù) 3.排列方向 4.子組件間距 三、格柵容器子組件 1.span 2.offset 3.order 四、

    2024年02月20日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包