使用 Bootstrap 使圖片響應


要使 Bootstrap 中的影像響應,可將類 .img-responsive 新增到 <img> 標記。此類將 max-width: 100%; 和 height: auto; 應用於影像,以便其很好地縮放為父級元素。

以下是如何簡單地使影像響應 -

示例

 即時演示

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <img src = "https://tutorialspoint.tw/python/images/python_data_science.jpg" class = "img-responsive" alt = "Online Training">
   </body>
</html>

更新於: 12-6-2020

6K+ 檢視

開啟你的 職業生涯

透過完成課程獲得認證

開始吧
廣告
© . All rights reserved.