使用 CSS max-width 屬性調整圖片大小


你可以嘗試使用以下程式碼來實現圖片響應式 max-width 屬性

示例

線上演示

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0">
      <style>
         img {
            max-width: 100%;
            height: auto;
         }
      </style>
   </head>
   <body>
      <p>To check the effect, you need to resize the browser.</p>
      <img src = "https://tutorialspoint.tw/python/images/python-data-science.jpg" alt = "Python Data Science" width = "400" height = "300">
   </body>
</html>

更新於: 2020-06-25

325 人觀看

開啟你的 職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.