I am facing an issue with adjusting the size of children elements based on their parent. The scenario is as follows:
HTML
<div class="video">
<div class="spot">
<img src="..." alt="">
<button>x</button>
</div>
</div>
CSS
.video {
width: 600px;
height: 500px;
background: #000;
position: relative;
}
.spot {
position: absolute;
max-height: 30px;
top: 0;
left: 0;
display: table;
margin: 0;
max-width: 100%;
/* width: 16%; only height can affect image on content*/
}
.spot img {
width: 100%;
height: 100%;
}
.spot button {
position: absolute;
top: 0;
left: 100%;
margin-left: -24px;
}
I want to ensure that the image adjusts its height according to the spot's height. Setting the width results in the image following the spot's width. Does anyone have a solution for this?
I have also created a jsfiddle https://jsfiddle.net/isatrio/yosfep6r/14/.