使用 CSS 中的百分比來設定影像的高度和寬度


要使用 % 設定影像的高度和寬度,你可以嘗試執行以下程式碼:

示例

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            height: 50%;
            width: 50%;
         }
      </style>
   </head>
   <body>
      <p>Sized image in %</p>
      <img src = "https://tutorialspoint.tw/videotutorials/assets/videos/courses/155/images/course_155_image.png" alt = "CSS" width = "200" height = "200">
   </body>
</html>

更新於: 2020 年 6 月 22 日

770 次瀏覽

開啟你的職業生涯

完成課程即可獲得認證

開始
廣告