Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

ตั้งค่าความสูงและความกว้างของรูปภาพโดยใช้เปอร์เซ็นต์ด้วย CSS


ในการตั้งค่าความสูงและความกว้างของรูปภาพโดยใช้ % คุณสามารถลองใช้รหัสต่อไปนี้ -

ตัวอย่าง

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