为什么图片被推下来?

huangapple go评论108阅读模式
英文:

why are the images being pushed down

问题

在我的代码中,最后一行的前两张图片被推下去了,请帮我将这些图片推回到它们应该的位置。

PS:我正在使用Bootstrap 3.4.1
PPS:这不应该做任何事情,所以你不需要修复它
PPPS:我可以稍后修复移动和平板电脑尺寸的问题,所以不用担心

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Image Gallery</title>
    <link rel="stylesheet" href="PH.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="#">Hungry Photos</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <li><a href="#">About <span class="sr-only">(current)</span></a></li>
                <li><a href="#">Contact</a></li>
              </ul>
              <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Sign Up</a></li>
                <li><a href="#">Login</a></li>
              </ul>
            </div><!-- /.navbar-collapse -->
          </div><!-- /.container-fluid -->
    </nav>

    <div class="container">
        <div class="jumbotron">
            <h1>The Image Gallery</h1>
            <p>A collection of selected pictures from multiple photographers</p>
        </div>

        <div class="row">
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <!-- 继续添加图片的代码 -->
        </div><!-- row collapse -->
    </div><!-- container collapse -->
    <script src="https://code.jquery.com/jquery-2.2.4.js" integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>
英文:

in my code, the first two images of the last row are being pushed down please help me push the images back up to where it is supposed to be

PS: I am using bootstrap 3.4.1
PPS: it shouldn't do anything so you don't have to fix that
PPPS: I can fix the mobile and tablet size problem later so don't worry about dat

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.navbar-default {
background-color: #2c3e50 !important;
}
nav a {
color: white !important;
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Image Gallery&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;PH.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;nav class=&quot;navbar navbar-default navbar-fixed-top&quot;&gt;
&lt;div class=&quot;container-fluid&quot;&gt;
&lt;!-- Brand and toggle get grouped for better mobile display --&gt;
&lt;div class=&quot;navbar-header&quot;&gt;
&lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-example-navbar-collapse-1&quot; aria-expanded=&quot;false&quot;&gt;
&lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Hungry Photos&lt;/a&gt;
&lt;/div&gt;
&lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
&lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-example-navbar-collapse-1&quot;&gt;
&lt;ul class=&quot;nav navbar-nav&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;About &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Up&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
&lt;/div&gt;&lt;!-- /.container-fluid --&gt;
&lt;/nav&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;jumbotron&quot;&gt;
&lt;h1&gt;The image Gallery&lt;/h1&gt;
&lt;p&gt;A collection of selected pictures from multiple photographers&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt; &lt;!-- row collapse --&gt;
&lt;/div&gt; &lt;!-- container collapse --&gt;
&lt;script src=&quot;https://code.jquery.com/jquery-2.2.4.js&quot; integrity=&quot;sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&quot; integrity=&quot;sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

it shouldn't do anything so don't try to fix that

答案1

得分: 2

只需删除你在col-lg-4之间添加的额外行,并将这个CSS添加到row类中,问题应该就能解决了。请检查一下。如果有任何更改,请告诉我。

.row {
  display: flex;
  flex-wrap: wrap;
}
英文:

Just remove the extra row which you have added in between of col-lg-4. and add this css of display: flex in a row class.

Please check. I hope it will solve your problem. If any changes please let me know.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.navbar-default {
background-color: #2c3e50 !important;
}
nav a {
color: white !important;
}
.row{
display: flex;
flex-wrap: wrap;
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Image Gallery&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;PH.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;nav class=&quot;navbar navbar-default navbar-fixed-top&quot;&gt;
&lt;div class=&quot;container-fluid&quot;&gt;
&lt;!-- Brand and toggle get grouped for better mobile display --&gt;
&lt;div class=&quot;navbar-header&quot;&gt;
&lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-example-navbar-collapse-1&quot; aria-expanded=&quot;false&quot;&gt;
&lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Hungry Photos&lt;/a&gt;
&lt;/div&gt;
&lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
&lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-example-navbar-collapse-1&quot;&gt;
&lt;ul class=&quot;nav navbar-nav&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;About &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Up&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
&lt;/div&gt;&lt;!-- /.container-fluid --&gt;
&lt;/nav&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;jumbotron&quot;&gt;
&lt;h1&gt;The image Gallery&lt;/h1&gt;
&lt;p&gt;A collection of selected pictures from multiple photographers&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt; &lt;!-- row collapse --&gt;
&lt;/div&gt; &lt;!-- container collapse --&gt;
&lt;script src=&quot;https://code.jquery.com/jquery-2.2.4.js&quot; integrity=&quot;sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&quot; integrity=&quot;sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

答案2

得分: 1

这是由于图像大小不同引起的。您需要在内容中添加相同大小(宽度 x 高度)的图像。或者您可以使用CSS设置高度。

英文:

It's happening because of different size of images. You have to add same size (width x height) images in you content. Or you can set height using css.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.navbar-default {
background-color: #2c3e50 !important;
}
nav a {
color: white !important;
}
div.thumbnail a&gt;img, div.thumbnail&gt;img {
height: 235px;
-o-object-fit: cover;
object-fit: cover;
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;title&gt;Image Gallery&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;PH.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;nav class=&quot;navbar navbar-default navbar-fixed-top&quot;&gt;
&lt;div class=&quot;container-fluid&quot;&gt;
&lt;!-- Brand and toggle get grouped for better mobile display --&gt;
&lt;div class=&quot;navbar-header&quot;&gt;
&lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-example-navbar-collapse-1&quot; aria-expanded=&quot;false&quot;&gt;
&lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Hungry Photos&lt;/a&gt;
&lt;/div&gt;
&lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
&lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-example-navbar-collapse-1&quot;&gt;
&lt;ul class=&quot;nav navbar-nav&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;About &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Up&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
&lt;/div&gt;&lt;!-- /.container-fluid --&gt;
&lt;/nav&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;jumbotron&quot;&gt;
&lt;h1&gt;The image Gallery&lt;/h1&gt;
&lt;p&gt;A collection of selected pictures from multiple photographers&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;img src=&quot;https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt; &lt;!-- row collapse --&gt;
&lt;/div&gt; &lt;!-- container collapse --&gt;
&lt;script src=&quot;https://code.jquery.com/jquery-2.2.4.js&quot; integrity=&quot;sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&quot; integrity=&quot;sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

答案3

得分: 0

你需要将每个col放在row中,以确保每个row中不超过12个col。这是bootstrap-grid结构的工作方式。

正如你在它们的官方文档中看到的,如果有12个col完成,下一个应该移到下一个row中。

"只有列可以是行的直接子元素"

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->
.navbar-default {
  background-color: #2c3e50 !important;
}
nav a {
  color: white !important;
}

<!-- language: lang-html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Image Gallery</title>
    <link rel="stylesheet" href="PH.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">


</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Hungry Photos</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li><a href="#">About <span class="sr-only">(current)</span></a></li>
            <li><a href="#">Contact</a></li>
              </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Sign Up</a></li>
            <li><a href="#">Login</a></li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    <div class="container">
        <div class="jumbotron">
            <h1>The image Gallery</h1>
            <p>A collection of selected pictures from multiple photographers</p>
        </div>

        <div class="row">
  <div class="col-lg-4">
    <div class="thumbnail">
      <img src="https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80" alt="">
    </div>
  </div>
  <div class="col-lg-4">
    <div class="thumbnail">
      <img src="https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
    </div>
  </div>
  <div class="col-lg-4">
    <div class="thumbnail">
      <img src="https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
    </div>
  </div>
  </div>
  <div class="row">
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
      </div>
    </div>
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
      </div>
    </div>
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
      </div>
    </div>
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
      </div>
    </div>
    <div class="col-lg-4">
      <div class="thumbnail">
        <img src="https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q

<details>
<summary>英文:</summary>

You need to wrap each `col` inside `row` so that there is no more then 12 `col` in a `row`. This is how the `bootstrap-grid` structure works.

&gt; As you can see in their official
&gt; [DOC](https://getbootstrap.com/docs/4.0/layout/grid/) that if `12
&gt; cols` complete the next should go to next `row`.

**

&gt; &quot;only columns may be immediate children of rows&quot;

**



&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;

&lt;!-- language: lang-css --&gt;

    .navbar-default {
      background-color: #2c3e50 !important;
    }
    nav a {
      color: white !important;
    }

&lt;!-- language: lang-html --&gt;

    &lt;!DOCTYPE html&gt;
    &lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;UTF-8&quot;&gt;
        &lt;title&gt;Image Gallery&lt;/title&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;PH.css&quot;&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu&quot; crossorigin=&quot;anonymous&quot;&gt;


    &lt;/head&gt;
    &lt;body&gt;
        &lt;nav class=&quot;navbar navbar-default navbar-fixed-top&quot;&gt;
          &lt;div class=&quot;container-fluid&quot;&gt;
            &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
            &lt;div class=&quot;navbar-header&quot;&gt;
              &lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-example-navbar-collapse-1&quot; aria-expanded=&quot;false&quot;&gt;
                &lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Hungry Photos&lt;/a&gt;
            &lt;/div&gt;

            &lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
            &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-example-navbar-collapse-1&quot;&gt;
              &lt;ul class=&quot;nav navbar-nav&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Up&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
          &lt;/div&gt;&lt;!-- /.container-fluid --&gt;
        &lt;/nav&gt;

        &lt;div class=&quot;container&quot;&gt;
            &lt;div class=&quot;jumbotron&quot;&gt;
                &lt;h1&gt;The image Gallery&lt;/h1&gt;
                &lt;p&gt;A collection of selected pictures from multiple photographers&lt;/p&gt;
            &lt;/div&gt;

            &lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-lg-4&quot;&gt;
        &lt;div class=&quot;thumbnail&quot;&gt;
          &lt;img src=&quot;https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80&quot; alt=&quot;&quot;&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;col-lg-4&quot;&gt;
        &lt;div class=&quot;thumbnail&quot;&gt;
          &lt;img src=&quot;https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;col-lg-4&quot;&gt;
        &lt;div class=&quot;thumbnail&quot;&gt;
          &lt;img src=&quot;https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-lg-4&quot;&gt;
          &lt;div class=&quot;thumbnail&quot;&gt;
            &lt;img src=&quot;https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;col-lg-4&quot;&gt;
          &lt;div class=&quot;thumbnail&quot;&gt;
            &lt;img src=&quot;https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;col-lg-4&quot;&gt;
          &lt;div class=&quot;thumbnail&quot;&gt;
            &lt;img src=&quot;https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;/div&gt;
      &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-lg-4&quot;&gt;
          &lt;div class=&quot;thumbnail&quot;&gt;
            &lt;img src=&quot;https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;col-lg-4&quot;&gt;
          &lt;div class=&quot;thumbnail&quot;&gt;
            &lt;img src=&quot;https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
          &lt;/div&gt;
        &lt;/div&gt;
          &lt;div class=&quot;col-lg-4&quot;&gt;
            &lt;div class=&quot;thumbnail&quot;&gt;
              &lt;img src=&quot;https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
            &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt; &lt;!-- row collapse --&gt;
        &lt;/div&gt; &lt;!-- container collapse --&gt;
        &lt;script src=&quot;https://code.jquery.com/jquery-2.2.4.js&quot; integrity=&quot;sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&quot; integrity=&quot;sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
    &lt;/body&gt;
    &lt;/html&gt;

&lt;!-- end snippet --&gt;


For more detail https://stackoverflow.com/questions/22053195/bootstrap-rows-and-columns-do-i-need-to-use-row


</details>



# 答案4
**得分**: 0

> 移除最后一列中的`&lt;div class=&quot;row&quot;&gt;`... 如果您使用了Bootstrap3,则需要添加`display:flex; flex-wrap:wrap`;如果您使用了Bootstrap4,则需要链接Bootstrap4 CDN链接...
> 
> 注意:此答案仅针对您的列,而不是整个页面。

```html
<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->
.navbar-default {
  background-color: #2c3e50 !important;
}
nav a {
  color: white !important;
}

<!-- language: lang-html -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Image Gallery</title>
    <link rel="stylesheet" href="PH.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Hungry Photos</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li><a href="#">About <span class="sr-only">(current)</span></a></li>
            <li><a href="#">Contact</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Sign Up</a></li>
            <li><a href="#">Login</a></li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    <div class="container">
        <div class="jumbotron">
            <h1>The image Gallery</h1>
            <p>A collection of selected pictures from multiple photographers</p>
        </div>

        <div class="row">
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
            <div class="col-lg-4">
                <div class="thumbnail">
                    <img src="https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60" alt="">
                </div>
            </div>
        </div> <!-- row collapse -->
    </div> <!-- container collapse -->
    <script

<details>
<summary>英文:</summary>

&gt; Remove`&lt;div class=&quot;row&quot;&gt;` in Last column... and if u used bootstrap3 u need to add `display:flex; flex-wrap:wrap`; and if u have used bootstrap 4, u need to Link Bootstrap4 CDN Link...
&gt; 
&gt; Note :- This answer in only for, your column not for full page..



&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;

&lt;!-- language: lang-css --&gt;

    .navbar-default {
      background-color: #2c3e50 !important;
    }
    nav a {
      color: white !important;
    }

&lt;!-- language: lang-html --&gt;

    &lt;link href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;/&gt;
    &lt;!DOCTYPE html&gt;
    &lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;UTF-8&quot;&gt;
        &lt;title&gt;Image Gallery&lt;/title&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;PH.css&quot;&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&quot; integrity=&quot;sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu&quot; crossorigin=&quot;anonymous&quot;&gt;


    &lt;/head&gt;
    &lt;body&gt;
        &lt;nav class=&quot;navbar navbar-default navbar-fixed-top&quot;&gt;
          &lt;div class=&quot;container-fluid&quot;&gt;
            &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
            &lt;div class=&quot;navbar-header&quot;&gt;
              &lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#bs-example-navbar-collapse-1&quot; aria-expanded=&quot;false&quot;&gt;
                &lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Hungry Photos&lt;/a&gt;
            &lt;/div&gt;

            &lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
            &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;bs-example-navbar-collapse-1&quot;&gt;
              &lt;ul class=&quot;nav navbar-nav&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Up&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
          &lt;/div&gt;&lt;!-- /.container-fluid --&gt;
        &lt;/nav&gt;

        &lt;div class=&quot;container&quot;&gt;
            &lt;div class=&quot;jumbotron&quot;&gt;
                &lt;h1&gt;The image Gallery&lt;/h1&gt;
                &lt;p&gt;A collection of selected pictures from multiple photographers&lt;/p&gt;
            &lt;/div&gt;

            &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1558981420-87aa9dad1c89?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=1050&amp;q=80&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577988504339-4dc891bdabe9?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577990174632-90bfb7da0119?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577949098254-1ad7b1b526eb?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577915378375-b18d2bd947c3?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577895752018-7eefa8a5a2dc?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577836660968-ef4cc3909bb2?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;thumbnail&quot;&gt;
                        &lt;img src=&quot;https://images.unsplash.com/photo-1577918285732-0ddce6230a88?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                    &lt;div class=&quot;col-lg-4&quot;&gt;
                        &lt;div class=&quot;thumbnail&quot;&gt;
                            &lt;img src=&quot;https://images.unsplash.com/photo-1577907796119-7118da053fab?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=500&amp;q=60&quot; alt=&quot;&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt; &lt;!-- row collapse --&gt;
        &lt;/div&gt; &lt;!-- container collapse --&gt;
        &lt;script src=&quot;https://code.jquery.com/jquery-2.2.4.js&quot; integrity=&quot;sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&quot; integrity=&quot;sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
    &lt;/body&gt;
    &lt;/html&gt;

&lt;!-- end snippet --&gt;



</details>



huangapple
  • 本文由 发表于 2020年1月3日 13:54:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/59573808.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定