Browser version
Firefox 79.0
When img
is used as a child element, and its height is set to 100% of the parent element, the expected phenomenon is that the width of the parent element is determined by the img. Eventually, in the Firefox
browser, the img
is scaled proportionally, but the width of the parent element is the child element original width. I can get the expected result in Google browser. The code show as below.
<div class="outer-est">
<div class="outer">
<div class="outer_container">
<div class="content_panel">
<div class="icon_panel">
<a href="" class="link_btn">
<img src="img/join_us/email.png" alt="">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
*{
margin: 0;
padding: 0;
}
.outer-est {
position: relative;
width: 100%;
}
.outer {
width: 62.5%;
margin: 0 auto;
}
.outer_container {
width: 100%;
/* height: 270px; */
padding-bottom: 30%;
position: relative;
}
.content_panel {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.icon_panel {
height: 20%;
display: inline-flex;
flex-direction: column;
justify-content: center;
}
.link_btn {
height: 100%;
}
.link_btn>img {
display: inline-block;
height: 100%;
width: auto;
}
</style>
My try
When I set a fixed height for
outer_container
, Firefox give me a expected result.