BootStrap 网格不工作,一行中的 col-XX-X 总是显示多行

BootStrap grid not working, col-XX-X in one row always shwing multi-row

我是bootstrap的初学者,只是用"Starter template"看网格结果,但是我看不到"col-lg-4"的三列显示在一行中,附加代码,我没有看到任何脚本错误, 我的显示分辨率为 1280 * 1024。请帮忙。多谢。

suppose in one row, but in 3 row


        <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>Bootstrap 101 Template</title>

        <!-- Bootstrap -->
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
      </head>
      <body>
        <h1>Hello, world!</h1>
    <div class="container">

            <div class="row">

                <div class="col-lg-4" style="border: 1px solid red;">11111</div>
                <div class="col-lg-4" style="border: 1px solid red;">22222</div>
                <div class="col-lg-4" style="border: 1px solid red;">33333</div>

            </div>
        </div>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
      </body>
    </html>

如果您的屏幕尺寸大于 1200px,该代码应该准确地为每个 div 提供 4 个网格,正如您指定的那样。在您使用的 bootstrap-3 中,lg 指定大于或等于 1200px 的屏幕。所以你的屏幕尺寸属于这一类。考虑下面的代码 -

<div class="row">

    <div class="col-lg-4" style="border: 1px solid red;">11111</div>
    <div class="col-lg-4" style="border: 1px solid red;">22222</div>
    <div class="col-lg-4" style="border: 1px solid red;">33333</div>

</div>
  • 您已使用<div class="col-lg-4"。这指定的是,当屏幕尺寸为 lg 时使用 4 个网格 bootstrap 网格系统,在所有其他情况下使用 12 个网格(如果没有为其他屏幕尺寸指定,这是默认值)。

您可以从 here. Make sure if its greater than 1200px. You can run the program from here 查看您的屏幕分辨率。你会看到,只要屏幕尺寸保持 >= 1200px,每个 divs 得到 4 个网格并保持在同一行。


如果每个 div 需要 3 个网格,而 col-lg-4 无法获得,您应该尝试 col-md-4,这将放置所有 div即使在中等尺寸的屏幕(笔记本电脑屏幕:992px - 1200px)上也可以在同一行,它应该适合你。