How To Make This You Tube Video Responsive? January 03, 2024 Post a Comment I have an you tube video in a wrapper. .center-block-horiz { margin-left: auto; margin-right: auto; } .border-5px-inset-4f4f4f { border: 5px inset #4f4f4f; } .set-padding { padding: 30px; } .responsive-wrapper { position: relative; height: 0; /* gets height from padding-bottom */ /* put following styles (necessary for overflow and scrolling handling on mobile devices) inline in .responsive-wrapper around iframe because not stable in CSS: -webkit-overflow-scrolling: touch; overflow: auto; */ } .responsive-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } #Iframe-Maison-Willem-Tell { max-width: 80%; max-height: 300px; overflow: hidden; } /* padding-bottom = h/w as % -- set aspect ratio */ .responsive-wrapper-wxh-600x480 { padding-bottom: 80%; } <!-- embed responsive iframe --><divclass="set-padding border-5px-inset-4f4f4f"><divid="Iframe-Maison-Willem-Tell"class="border-5px-inset-4f4f4f center-block-horiz"><divclass="responsive-wrapper responsive-wrapper-wxh-600x480"style="-webkit-overflow-scrolling: touch; overflow: auto;"><!-- style overflow and overflow-scrolling inline because not stable in CSS --><iframesrc="http://maisonwillemtell.be"><pstyle="font-size: 110%;"><em><strong>IFRAME: </strong> There is iframe content being displayed here but your browser version does not support iframes. </em> Please update your browser to its most recent version and try again.</p></iframe></div></div></div>CopyThe result can be seen in the Pen Responsive Iframe - Base Code.The markup and CSS and the rationale behind them are taken from How to Make Responsive Iframes — it’s easy! and from Scaling iframes for responsive design CSS-only.One salient point is to remove all styling from the <iframe> tag. Style with CSS only, with the exception of overflow-scrolling and overflow which are styled inline in the <div> wrapper around the <iframe>. Another point is to set width and height be setting max-width and max-height in the <div> wrapper around .responsive-wrapper.The outer most <div> is not necessary; it's just there to show the effects of padding and border.To position the iframe left you might use flex box instead of float. Share Post a Comment for "How To Make This You Tube Video Responsive?"
Post a Comment for "How To Make This You Tube Video Responsive?"