.boxGallery {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-left: auto;
  margin-right: auto;
  width: 80%;
}

.gallery {
  min-width: 320px;
  width: 50%;
  margin: 12px;
  float: left;
}

.gallery img {
  width: 100%;
  height: auto;
  padding: 5px;
  border-radius: 12px;
}

.desc {
  padding: 15px;
  text-align: center;
}

<div class="boxGallery">
  <div class="gallery">
    <img src="https://placeimg.com/640/480/any">
  </div>

  <div class="gallery">
    <img src="https://placeimg.com/640/480/any">
  </div>
</div>

<div class="desc">
  <p>Auvergne, Frankrijk 2018</p>
</div>

<div class="boxGallery">
  <div class="gallery">
    <img src="https://placeimg.com/640/480/any">
  </div>

  <div class="gallery">
    <img src="https://placeimg.com/640/480/any">
  </div>
</div>





我试图做一个照相馆。问题是我无法使图像彼此相邻。因此,我想要的是:我想要在照片的每个部分上方放置一个标题,该部分必须居中,并且多个图像应能够根据页面的大小彼此相邻。最后一件事是我无法上班(截图)。我真的不知道该如何解决。任何人有想法吗?

SCREENSHOT

最佳答案

如果您具有Bootstrap的基本知识。您可以使用以下示例制作照片库。
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_img_thumbnail2&stacked=h

另一个例子

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<div class="row">
    <div class="col-md-4">
  <h2>Rounded Corners</h2>
  <p>The .img-rounded class adds rounded corners to an image (not available in IE8):</p>
  <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre" width="304" height="236">
  </div>
  <div class="col-md-4">
  <h2>Rounded Corners</h2>
  <p>The .img-rounded class adds rounded corners to an image (not available in IE8):</p>
  <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre" width="304" height="236">
  </div>
  <div class="col-md-4">
  <h2>Rounded Corners</h2>
  <p>The .img-rounded class adds rounded corners to an image (not available in IE8):</p>
  <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre" width="304" height="236">
  </div>
  <div class="col-md-4">
  <h2>Rounded Corners</h2>
  <p>The .img-rounded class adds rounded corners to an image (not available in IE8):</p>
  <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre" width="304" height="236">
  </div>
  <div class="col-md-4">
  <h2>Rounded Corners</h2>
  <p>The .img-rounded class adds rounded corners to an image (not available in IE8):</p>
  <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre" width="304" height="236">
  </div>
</div>
</div>

</body>
</html>

关于html - 如何将图像彼此相邻放置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52956785/

10-11 08:12