My iframe is left aligned and I'm having trouble centering it.
.iframeContainer {
display: inline-block;
justify-content: center; /* Center the iframe horizontally */
align-items: center;
width: 1067px;
height: 600px;
}
<div class="iframeContainer">
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/vFO0_PA_NAg?si=VeD7R53zMk8l3yw8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
Resizing the iframe directly in the HTML document seems to work:
<div class="iframeContainer">
<iframe width="1067px" height="600px" src="https://www.youtube.com/embed/vFO0_PA_NAg?si=VeD7R53zMk8l3yw8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
The CSS should be like:
.iframeContainer {
display: flex;
justify-content: center;
align-items: center;
}
I also tried using margin:auto, but that didn't help either.
I may be mistaken since I'm new to coding, but I think an iframe is a block element, so I find it puzzling that it works as a flex. Consistency is important, so any advice on this issue would be greatly appreciated.