【发布时间】:2018-09-21 15:38:00
【问题描述】:
我正在尝试对一个面板进行响应式设计,该面板由一个图像和另一个具有自己内部元素的容器并排组成。
我有一个父 div 和一个 img 和另一个 div 标签。这两个子标签是浮动块,宽度为 % 并且有效。
问题是,当我缩小页面时,img 会缩小以遵守 % width 规则,它的高度也是如此,它应该保持这种状态,但侧面的 div 不会将其高度更改为相同作为兄弟图像。
我将它们包裹在另一个 div 中,并将内部 div 放在 height: 100% 的位置,希望可以解决问题,但没有。
我想获取正确的 div 以根据左侧图像更改其高度。
.img-container {
display: block;
width: 59%;
float: left;
}
img {
width: 100%;
}
.product-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 41%;
float: left;
background-color: #e4d233;
}
.product-img {
width: 45%
}
<div class="imgProductContainer">
<div class="img-container">
<img src="http://pngimg.com/uploads/running_shoes/running_shoes_PNG5815.png"/>
</div>
<div class="product-container">
<img id="product2Img" class="product-img" src="http://pluspng.com/img-png/png-gym-shoes-shoe-away-hunger-is-a-partnering-program-where-footwear-is-turned-around-to-provide-an-eco-friendly-means-of-support-for-our-feeding-the-futures-programs-520.png">
<p><span id="product2Name"></span><br>
<span>2.00 €</span></p>
</div>
</div>
【问题讨论】:
-
是否有理由为产品容器 div 设置了固定高度?删除它,你应该得到你正在寻找的东西。
-
哎呀!这是我试图解决我忘记保留帖子的问题之一。可悲的是,这仍然不能解决问题,img-container 和 product-container 有不同的高度 :(