我想将图像与 div 底部对齐,并水平居中。这是我想要实现的效果(下面有图片),但在我的项目中,牛下方有一个巨大的间隙。牛的图片被切成两半,因此我希望底部部分能够粘贴到视口底部并具有响应性。
HTML:
<div class="main">
<div class="container">
<div class="nav">
<ul>
<li><a href="index.html" >Work</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="main_text">
<h1>Awh Cow! I got no <span class="yellow">Dribbble</span>.</h1>
<p>Invite me to Dribbble maybe? Thanks.</p>
</div>
<a href="mailto:hi@gauthamsk.com" class="button">Visit Profile</a>
<div class="cow"></div>
</div> <!-- end container -->
</div> <!-- end main -->
CSS:
.cow {
height: 280px; /* Change this height to change the size of the cow */
background: url(../images/cow.png) bottom center no-repeat;
background-size: contain;
}