【问题标题】:Buttom alignment of pictures in af row with different hight不同高度的连续图片按钮对齐
【发布时间】:2017-12-07 00:29:49
【问题描述】:

我正在使用包含此模板的 8 张图片的部分作为相册。

Template

但是,如果我的图片有不同的高度,它们会被对齐,这样图片的顶部就会相互匹配。我需要它们对齐,所以图像的底部是对齐的。

我该怎么做?

【问题讨论】:

  • 欢迎来到StackOverflow,请在提问时更具体一点:到目前为止,您对代码示例做了哪些尝试? (I downvoted because there is no code) / 你期望什么? / 你会遇到什么错误? 请查看“How to ask”以获得帮助

标签: alignment


【解决方案1】:

我的链接同时显示了代码和我使用的模板:-) 这段代码的问题是 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2014-08-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多