使用 Bootstrap 清除元素浮動


若要清除元素浮動,請使用 Bootstrap 類 .clearfix。

示例

你可以嘗試執行以下程式碼來清除元素浮動。

立即演示

<!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>
      <div class = "clearfix" style = "background: orange;border: 1px solid #000; padding: 10px;">
         <div class = "pull-left" style = "background: blue; color: white;">
            left
         </div>
         <div class = "pull-right" style = "background: blue; color:white;">
            right
         </div>
      </div>
   </body>
</html>

更新於:2020 年 6 月 12 日

445 次瀏覽

開啟你的 職業生涯

完成本課程並獲得認證

開始
廣告
© . All rights reserved.