範例 2 - 側邊固定式選單
基本樣式範例練習網址: https://codepen.io/peiqun/pen/QXOwjK
完整範例網址: https://codepen.io/peiqun/pen/aPvKwL
HTML 結構
<div class="all">
  <div class="menu">
    <img src="path/to/img" width="200" alt="">
    <div class="list">
      <p>回到首頁</p>
      <p>關於我們</p>
      <p>熱銷產品</p>
      <p>購物車</p>
    </div>
    <div class="copy">
      07-1234-5678 <br>
      [email protected] <br>
      800 高雄市新興區幸福路 520 號
    </div>
  </div>
  <div class="content">
    <div class="container">
      <h3>集使濟業看</h3>
      <p>...</p>
      <div class="product">
        <div class="sweet"></div>
        <div class="sweet"></div>
        <div class="sweet"></div>
        <div class="sweet"></div>
        <div class="sweet"></div>
        <div class="sweet"></div>
      </div>
      <h4>特要名得家到的學之點大得過不</h4>
      <p>...</p>
    </div>
  </div>
</div>步驟解析
- 基本樣式設定
  - 在 .all上設定100%高度
- 在 .menu上設定字體、背景顏色和50px上下內距
- 在 .content上設定overflow-y: auto,讓內容超過設定寬度時加上滾輪,並設定內距讓視覺上看起來不會太擠
- 在 .sweet上設定高度、背景圖片及邊框,並設定box-sizing: border-box調整大小計算方式
 
 
- 在 
- 在 .all上設定display: flex將內容並排
  
- 在 .menu上設定flex: 0 1 350px,讓選單寬度不超過350px;
 .content設定flex: 1 1 500px,開放寬度的伸縮功能,來配置版面。
  
- 在 .menu加上display: flex的效果
  
- 透過 flex-direction將.menu內容設定為垂直排列,並設定align-items: center將交錯軸內容置中對齊
  
- 透過 justify-content: space-between將內容對齊主軸線最前端與最末端
  
- 在 .product加上display: flex的效果,並透過flex的設定賦予.sweet寬度
  
- 在 .product上設定flex-wrap: wrap,加上斷行效果
 