【发布时间】:2021-08-20 06:31:18
【问题描述】:
有一个名为 article 两个子 div 的容器,其中一个具有图像作为背景,另一个具有文本。 我在 max width:700 px 处设置了一个断点,将其更改为 coulmn 并将图像的宽度(具有文章预览类)更改为 100 % flex 为无。 但是当我调整大小时,尽管宽度为 100 %,但图像的大小正在增长和缩小,但在某些时候,可以看到一半的图像没有显示完整的长度。
<div class="container">
<div class="article">
<div class="article-preview"></div>
<div class="article-info">
<h1>
Have the courage to follow your heart and intuition.
</h1>
<p>
Steve Jobs was is one of the most respected entrepreneurs and inventors of his time. In 1976 he founded Apple together with his friend Steve Wozniak. They created their first computer, the Apple I, in the garage of Jobs’ parents.
</p>
<div class="article-author">
<i class="fa fa-apple" aria-hidden="true"></i>
<div class="author-info">
<span class="author-name">Steven Paul Jobs</span>
<span class="date">28 Jun 2020</span>
</div>
</div>
</div>
</div>
</div>
.article {
height: 280px;
max-width: 700px;
display: flex;
flex-direction: row;
}
/* Article Preview Section */
.article-preview {
height: 280px;
width: 290px;
width: 100%;
background: url('https://images.unsplash.com/photo-1591843336309-cbf414ad7978?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1567&q=80g');
background-size: cover;
background-position: top center;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
flex: 1;
}
/* Article Info Section */
.article-info {
flex: 1.19;
background: #ffff;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
padding-left: 40px;
padding-right: 35px;
padding-top: 25px;
padding-bottom: 30px;
position: relative;
}
.article-info h1 {
font-size: 20px;
line-height: 1.5;
margin-bottom: 15px;
}
.article-info p {
font-size: 12px;
line-height: 1.5;
margin-bottom: 20px;
padding-right: 8px;
}
@media (max-width: 700px) {
.article{
height: auto;
display: flex;
flex-direction: column;
}
.article-preview{
width: 100%;
flex: none;
border-top-right-radius: 10px;
border-bottom-left-radius: 0px;
height: 280px;
}
}
【问题讨论】:
-
我希望你想要实现的是当屏幕尺寸低于 700px 时,图像应该是完全可见的。
-
是的,它不完全可见,它变大了
标签: css flexbox responsive