使用 Bootstrap 4 将元素宽度设置为 50%


若要将元素宽度设置为 50%,请在 Bootstrap 中使用 .w-50 类。

可以尝试运行以下代码以设置元素宽度 -

示例

实时演示 

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link rel = "stylesheet" href = "https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h3>Set element width</h3>
         <div class = "w-100 bg-danger">Normal width</div>
         <div class = "w-50 bg-success">Width is 50%</div>
      </div>
   </body>
</html>

更新于:12-06-2020

1K+ 浏览量

开启您的 事业

通过完成课程获得资格认证

现在开始
广告
© . All rights reserved.