EDIT: Trying to reword the question so that the problem is understood correctly
I have a div element within which there is a video element. The div element is resizable. The video element needs to be resizable too but it also needs to keep its original aspect ratio.
.container {
background: #ff9;
height: 150px;
width: 100px;
}
.subcontainer {
background: #9ff;
min-width: 100%;
min-height: 100%;
margin: 5px;
}
.fixedsize{
background: #9f9;
}
<div class="container">
<div class="subcontainer">
<video class="fixedsize" src="https://media.giphy.com/media/3ohryjnGyiSRrGWKn6/giphy-hd.mp4" poster="https://media.giphy.com/media/3ohryjnGyiSRrGWKn6/giphy_s.gif" autoplay="" loop="" playsinline=""></video>
</div>
</div>
So I need, the video element here to be centered both horizontally and vertically without losing the aspect ratio of it.
.container {
background: #ff9;
height: 400px;
width: 1000px;
}
.subcontainer {
background: #9ff;
min-width: 100%;
min-height: 100%;
margin: 5px;
}
.fixedsize {
background: #9f9;
}
<div class="container">
<div class="subcontainer">
<video class="fixedsize" src="https://media.giphy.com/media/3ohryjnGyiSRrGWKn6/giphy-hd.mp4" poster="https://media.giphy.com/media/3ohryjnGyiSRrGWKn6/giphy_s.gif" autoplay="" loop="" playsinline=""></video>
</div>
</div>
In this case, I want the video to stretch vertically and then centered horizontally.
Similar case for where the width of container is greater than the video width; I'd want the video to stretch horizontally and centered vertically.
Is this possible with only css?