Responsive Web Design
  • Responsive Web Design 課程
  • 1 簡介
    • 1.1 講者簡介
    • 1.2 課程簡介
  • 2 版面概念解析
  • 3 Media Query
    • 3.1 媒體類型 Media Type
    • 3.2 媒體描述 Media Features
    • 3.3 練習
  • 4 Viewport
    • 4.1 Viewport 定義
    • 4.2 HTML Viewport Meta
  • 5 Bootstrap Grid System
    • 5.1 載入 Grid 相關 CSS
    • 5.2 Grid System
    • 5.3 breakpoint 練習
  • 6 Transition 轉場效果
    • 6.1 第一個 transition
    • 6.2 transition-property
    • 6.3 transition-duration
    • 6.4 transition-timing-function
    • 6.5 transition-delay
    • 6.6 transition 簡寫
    • 6.7 練習
  • 7 Grid 排版模式
    • 7.1 基本觀念及術語
    • 7.2 Grid Container
    • 7.3 Grid Items
    • 7.4 練習
  • 8 Animation 動畫效果
    • 8.1 第一個 animation
    • 8.2 關於 keyframes
    • 8.3 相同元素套用多個 animation
    • 8.4 animation-iteration-count
    • 8.5 animation-direction
    • 8.6 animation-delay
    • 8.7 animation-fill-mode
    • 8.8 animation-play-state
    • 8.9 animation-timing-function
    • 8.10 animation 簡寫
    • 8.11 練習
  • 9 練習
  • 10 RWD 作業
  • 11 手機連本機端網站
  • 12 參考資料
  • 13 補充:AOS
Powered by GitBook
On this page
  • grid-column
  • grid-row
  • grid-area
  • 排列相關
  • justify-self
  • align-self
  • place-self
  1. 7 Grid 排版模式

7.3 Grid Items

grid-column

  • 數值指的是 Grid Column Line 的意思。

  • span 2:指的是擴展兩個欄的意思。

/* 寫法一 */
grid-column: 1 / 3;
grid-column: -4 / -2; /* 反過來數 */

/* 寫法二 */
grid-column-start: 1;
grid-column-end: 3;

/* 寫法三 */
grid-column: 1 / span 2;


/* 寫法四:使用 line 的命名 */
/*
使用 Grid Line 的名稱,假設在 Grid Container 有設定:
grid-template-columns: [a] auto [b] auto [c] auto [d];
*/
grid-column: a / c;

例:

grid-row

  • 數值指的是 Grid Row Line 的意思。

  • span 2:指的是擴展兩個欄的意思。

/* 寫法一 */
grid-row: 1 / 4;
grid-row: -4 / -1; /* 反過來數 */

/* 寫法二 */
grid-row-start: 1;
grid-row-end: 4;

/* 寫法三 */
grid-row: 1 / span 3;

/* 寫法四:使用 line 的命名 */
/*
使用 Grid Line 的名稱,假設在 Grid Container 有設定:
grid-template-rows: [a] auto [b] auto [c] auto [d];
*/
grid-row: a / d;

例:

grid-area

原來九個欄位如下:

將 4 的那個欄位,擴展到 4、5、7、8,變成如下:

/* 寫法一 */
grid-row-start: 2;
grid-column-start: 1;
  
grid-row-end: 4;
grid-column-end: 3;

/* 寫法二 */
grid-area: 2 / 1 / 4 / 3;

/* 寫法三 */
grid-area: 2 / 1 / span 2 / span  2;

例 1:使用 Grid Line 來設定範圍:

例 2:使用 grid-area 來將欄位指定位置(例:將 1 和 9 對調):

例 3: grid-area 也可以用來設定這個 Item 的名稱,然後就可以在 Grid Container 中使用 grid-template-areas 中直接指定名稱。

div.item{
  grid-area: header;
}

範例請參考 grid-template-areas 屬性。

排列相關

justify-self

請參考 justify-items。

align-self

請參考 align-items。

place-self

請參考 place-items。

是 justify-self 和 align-self 的簡寫形式,格式如下:

place-self: <align-self> <justify-self>;

Previous7.2 Grid ContainerNext7.4 練習

Last updated 1 year ago