【发布时间】:2021-02-13 17:34:24
【问题描述】:
我很难让我的图像与我的 div 一起伸展。宽度按预期响应,但高度未达到 div 的底部,因为它随着窗口屏幕变小而在高度上扩展。
HTML:
<div class="post-container">
<div class="post-thumb">
<img src="JKPWQF96-G01-121526-500px-650px.jpg" alt="client">
</div>
<div class="post-content">
<h1>Nathan Bayne</h1><br>
<h2>Software Developer</h2><br>
<p>This is dummy text!</p><br>
<p>This is dummy text!</p><br>
<p>This is dummy text!</p>
<a href="#" class="button instagram"><span class="gradient"></span>Full Bio</a>
<a href="#" class="button2 instagram"><span class="gradient"></span>Contact</a>
<div class="social-buttons">
<a href="#"><i class="fab fa-twitter"></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
<a href="#"><i class="fab fa-youtube"></i></a>
<a href="#"><i class="fab fa-linkedin-in"></i></a>
</div>
</div>
<div class="copyright">
<p>© Nathan Bayne, 2020. All rights reserved.</p>
</div>
</div>
CSS:
/*Sets colour, width, border, height and margins of the main div where the image and text are within*/
.post-container {
background-color: #000;
width: 70%;
margin: 3% 15% 3% 15%;
height: 100%;
border: 1px solid #FFFFFF;
}
/*Makes adjustments to width of the main image (covers 35% of post-container div)*/
.post-thumb {
width: 35%;
height: 100%;
float: left;
}
/*Makes adjustments to the image and allows the image to be outwith the div space to allow a higher quality image*/
.post-thumb img{
width: 100%;
height: 100%;
background-size: 100%;
object-fit: cover;
border: solid #FFFFFF;
border-width: 0px 1px 0px 0px;
display: block;
}
这是当前屏幕的样子:
【问题讨论】:
标签: html css image responsive responsive-images