使用 CSS 百分比设置图片的高度和宽度

cssweb developmentfront end technology更新于 2024/4/5 9:48:17

要使用 % 设置图片的高度和宽度,您可以尝试运行以下代码 −

示例

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

相关文章


有用资源