Layout (佈局)

@media

/* 手機裝置樣式 */
@media (max-width: 768px) {
  /* 手機螢幕的樣式 */
}

/* PC 裝置樣式 */
@media (min-width: 769px) {
  /* PC 螢幕的樣式 */
}

display

none

block

flex

grid

inline

inline-block

inline-flex

inline-grid

table

table-row

table-cell

contents

list-item

position

static

relative

.relative-element {
    position: relative;
    top: 10px; /* 向下移動 10 px */
}

absolute

.absolute-element {
  position: absolute;
  top: 50px; /* 參考父元素的上方邊緣 */
  left: 30px; /* 參考父元素的左側邊緣 */
}

fixed

.fixed-element {
  position: fixed;
  bottom: 0; /* 固定在視窗的下方 */
  right: 0; /* 固定在視窗的右側 */
}

sticky

.sticky-element {
  position: sticky;
  top: 0; /* 當滾動到距離頂部 0px 時變為固定位置 */
}

Flexbox 佈局

父層設置

flex-direction

flex-wrap

justify-content

align-items

align-content

子層設置

order

flex-grow

flex-shrink

flex-basis

flex

align-self

Grid 佈局

grid-template-columns

grid-template-rows

grid-column

grid-row

gap

justify-items

align-items

grid-template-areas

索引