圖片 01|背景與底圖

用 CSS 設定背景,重要圖片仍用 img。

重點與範例

body { background-color: #181326; }
.banner {
  background-image: url("images/lesson-photo.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  height: 180px;
}

cover 鋪滿區域,圖片可能被裁切。背景圖適合裝飾,不帶 alt;需要傳達內容的圖片請用 img。

動手改一處

把 cover 改成 contain,比較完整顯示與鋪滿的差異。