So I have made a youtube video and embedded it on my website and centered it with display: block; margin: auto; but when I apply responsiveness the video losses its centered position. So I want to know how to keep it centered at all times.
HTML AND CSS
HTML
<div class="video-container">
<iframe width="727" height="409" src="https://www.youtube.com/embed/YwUNFRGU3q8" title="Reality and Expectation - What You See And What You Expect To See - Planets" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" style="display: block; margin: auto;" allowfullscreen></iframe>
</div>
CSS
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe, .video-container object, .video-container embed {
position: absolute;
top: 0;
left: 0;
width: 80%;
height: 80%;
}