如何在保持图像纵横比的同时阻止图像扩展我的Flex容器?
因此,无论我在将其放置在Flex容器中头顶右
时尝试使用哪种图像,它都会在扭曲旁边的图像时扩展我的挠性容器,并扩展外部挠曲容器。我如何放置任何图像,同时也没有扩展图像所在的flex项目并扭曲其旁边的图像。我有Max-Height:100%;
,但这没有帮助,我认为这是因为父容器没有高度集。这是可能的吗?
.head {
grid-column: 2/3;
grid-row: 1/2;
border: solid 1px red;
padding: 38px 40px;
}
.head-top {
display: flex;
}
.head-search {
width: 40%;
border-radius: 15px;
background-color: lightgrey;
}
.search-img {
margin-right: 15px;
}
.head-top-right {
display: flex;
width: 45%;
margin-left: 30px;
border: solid black 1px;
}
.head-profile-pic {
max-height: 100%;
}
<div class="head">
<div class="head-top">
<img src="pic/magnify.png" class="search-img">
<input type="text" name="search" class="head-search" />
<div class="head-top-right">
<img src="pic/notifications.png">
<img src="pic/earth.jpg" class="head-profile-pic">
</div>
</div>
</div>
So no matter what image I try to use when placing it in the flex container head-top-right
, it expands my flex container while distorting the image next to it and also expands the outer flex container. How do I place any image while also not expanding the flex item the image is in and also distorting the images next to it. I have max-height:100%;
but it's not helping and I assume that it's because the parent container does not have a height set. Is that a possibility?
.head {
grid-column: 2/3;
grid-row: 1/2;
border: solid 1px red;
padding: 38px 40px;
}
.head-top {
display: flex;
}
.head-search {
width: 40%;
border-radius: 15px;
background-color: lightgrey;
}
.search-img {
margin-right: 15px;
}
.head-top-right {
display: flex;
width: 45%;
margin-left: 30px;
border: solid black 1px;
}
.head-profile-pic {
max-height: 100%;
}
<div class="head">
<div class="head-top">
<img src="pic/magnify.png" class="search-img">
<input type="text" name="search" class="head-search" />
<div class="head-top-right">
<img src="pic/notifications.png">
<img src="pic/earth.jpg" class="head-profile-pic">
</div>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论