不同高度的af行中图片的对齐

时间:2017-12-06 14:35:04

标签: alignment

我正在使用这个模板的8个图像的部分作为照相馆。

Template

但是如果我的图像具有不同的高度,它们将被对齐,因此图像的顶部将彼此适合。我需要它们对齐,所以图像的底部是对齐的。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

我的链接显示了我使用的代码和模板:-)此代码的问题是8个图像的垂直对齐,如果它们有不同的高度。它们将对齐,以使图像的顶部彼此适合。我需要的是,8幅图像是相互对齐的。

<!DOCTYPE html>
<html>
<title>W3.CSS Template</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karma">
<style>
body,h1,h2,h3,h4,h5,h6 {font-family: "Karma", sans-serif}
.w3-bar-block .w3-bar-item {padding:20px}
</style>
<body>

<!-- Sidebar (hidden by default) -->
<nav class="w3-sidebar w3-bar-block w3-card w3-top w3-xlarge w3-animate-    left" style="display:none;z-index:2;width:40%;min-width:300px" id="mySidebar">
<a href="javascript:void(0)" onclick="w3_close()"
  class="w3-bar-item w3-button">Close Menu</a>
  <a href="#food" onclick="w3_close()" class="w3-bar-item w3-button">Food</a>
  <a href="#about" onclick="w3_close()" class="w3-bar-item w3-button">About</a>
  </nav>

<!-- Top menu -->
<div class="w3-top">
<div class="w3-white w3-xlarge" style="max-width:1200px;margin:auto">
<div class="w3-button w3-padding-16 w3-left" onclick="w3_open()">☰</div>
<div class="w3-right w3-padding-16">Mail</div>
<div class="w3-center w3-padding-16">My Food</div>
</div>
</div>

<!-- !PAGE CONTENT! -->
<div class="w3-main w3-content w3-padding" style="max-width:1200px;margin-top:100px">

 <!-- First Photo Grid-->
 <div class="w3-row-padding w3-padding-16 w3-center" id="food">
 <div class="w3-quarter">
 <img src="/w3images/sandwich.jpg" alt="Sandwich" style="width:100%">
 <h3>The Perfect Sandwich, A Real NYC Classic</h3>
 <p>Just some random text, lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/steak.jpg" alt="Steak" style="width:100%">
 <h3>Let Me Tell You About This Steak</h3>
 <p>Once again, some random text to lorem lorem lorem lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/cherries.jpg" alt="Cherries" style="width:100%">
 <h3>Cherries, interrupted</h3>
 <p>Lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 <p>What else?</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/wine.jpg" alt="Pasta and Wine" style="width:100%">
 <h3>Once Again, Robust Wine and Vegetable Pasta</h3>
 <p>Lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 </div>

 <!-- Second Photo Grid-->
 <div class="w3-row-padding w3-padding-16 w3-center">
 <div class="w3-quarter">
 <img src="/w3images/popsicle.jpg" alt="Popsicle" style="width:100%">
 <h3>All I Need Is a Popsicle</h3>
 <p>Lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/salmon.jpg" alt="Salmon" style="width:100%">
 <h3>Salmon For Your Skin</h3>
 <p>Once again, some random text to lorem lorem lorem lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/sandwich.jpg" alt="Sandwich" style="width:100%">
 <h3>The Perfect Sandwich, A Real Classic</h3>
 <p>Just some random text, lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 <div class="w3-quarter">
 <img src="/w3images/croissant.jpg" alt="Croissant" style="width:100%">
 <h3>Le French</h3>
 <p>Lorem lorem lorem lorem ipsum text praesent tincidunt ipsum lipsum.</p>
 </div>
 </div>

 <!-- Pagination -->
 <div class="w3-center w3-padding-32">
 <div class="w3-bar">
 <a href="#" class="w3-bar-item w3-button w3-hover-black">«</a>
 <a href="#" class="w3-bar-item w3-black w3-button">1</a>
 <a href="#" class="w3-bar-item w3-button w3-hover-black">2</a>
 <a href="#" class="w3-bar-item w3-button w3-hover-black">3</a>
 <a href="#" class="w3-bar-item w3-button w3-hover-black">4</a>
 <a href="#" class="w3-bar-item w3-button w3-hover-black">»</a>
 </div>
 </div>

  <hr id="about">

  <!-- About Section -->
  <div class="w3-container w3-padding-32 w3-center">  
  <h3>About Me, The Food Man</h3><br>
  <img src="/w3images/chef.jpg" alt="Me" class="w3-image" style="display:block;margin:auto" width="800" height="533">
  <div class="w3-padding-32">
  <h4><b>I am Who I Am!</b></h4>
  <h6><i>With Passion For Real, Good Food</i></h6>
  <p>Just me, myself and I, exploring the universe of unknownment. I have a heart f love and an interest of lorem ipsum and mauris neque quam blog. I want to share my world with you. Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla. Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.</p>
   </div>
   </div>
   <hr>

  <!-- Footer -->
  <footer class="w3-row-padding w3-padding-32">
  <div class="w3-third">
  <h3>FOOTER</h3>
  <p>Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.</p>
  <p>Powered by <a href="https://www.w3schools.com/w3css/default.asp" target="_blank">w3.css</a></p>
  </div>

  <div class="w3-third">
  <h3>BLOG POSTS</h3>
  <ul class="w3-ul w3-hoverable">
  <li class="w3-padding-16">
  <img src="/w3images/workshop.jpg" class="w3-left w3-margin-right" style="width:50px">
  <span class="w3-large">Lorem</span><br>
  <span>Sed mattis nunc</span>
  </li>
  <li class="w3-padding-16">
  <img src="/w3images/gondol.jpg" class="w3-left w3-margin-right" style="width:50px">
  <span class="w3-large">Ipsum</span><br>
  <span>Praes tinci sed</span>
  </li> 
  </ul>
  </div>

  <div class="w3-third w3-serif">

  </footer>

<!-- End page content -->
</div>

<script>
// Script to open and close sidebar
function w3_open() {
     document.getElementById("mySidebar").style.display = "block";
}

function w3_close() {
     document.getElementById("mySidebar").style.display = "none";
}
</script>

 </body>
 </html>enter code here