圖片 05|圖文對齊

用 Flex 排列圖片與文字。

重點與範例

<div class="photo-row">
  <img src="images/lesson-photo.svg" alt="山景示意圖">
  <p>這是圖片旁邊的說明。</p>
</div>
<style>
.photo-row { display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.photo-row img { width:180px; max-width:100%; height:auto; }
</style>
山景示意圖

這是圖片旁邊的說明。

align-items 控制垂直對齊,gap 控制間隔;flex-wrap 讓空間不足時換行。圖片單獨置中,可用 display:block; margin:0 auto;。

動手改一處

將 align-items 改成 flex-start,觀察頂端對齊。