首頁  >  文章  >  web前端  >  CSS object-fit 屬性值

CSS object-fit 屬性值

WBOY
WBOY轉載
2023-09-02 10:17:021176瀏覽

CSS object-fit 属性值

CSS 中的 object-fit 屬性用於調整映像或影片的大小以適合其容器。它具有以下值

  • 包含:縮放內容以適應
  • #封面:剪裁以適應
  • #填滿:填滿內容框。

範例 h2>

您可以嘗試執行以下程式碼來實作帶有 cover 值的 object-fit 屬性。

現場示範 p>

<!DOCTYPE html>
<html>
   <head>
      <style>
         .myimg {
            width:250px;
            height:350px;
            object-fit:fill;
         }
      </style>
   </head>
   <body>
      <h2>SWIFT</h2>
      <img class = "myimg"
         src = "https://www.tutorialspoint.com/assets/videos/courses/67/images/course_67_image.png"
         alt = "Python Data Science" width = "300" height = "200">
   </body>
</html>

#

以上是CSS object-fit 屬性值的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除