The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> changing YT embed size, Please help, I am very new to HTML
gatorworld
post Jun 14 2022, 02:30 PM
Post #1





Group: Members
Posts: 4
Joined: 8-April 22
Member No.: 28,310



Hello, I need to resize this youtube embed. I am very new to HTML

I fixed the width. It is looking right on all devices, but the height is squished. What should I do to fix this?

IPB Image

Thanks in advance

<iframe width="100%" height="100%" src="https://www.youtube.com/embed/wvNH28d3NN8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jun 14 2022, 03:31 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



100% height doesn't work the way you think and even if it did the clip would be distorted.

Stick to pixels and keep the original aspect ratio. The size google suggests is that's 560x315 so you could use for instance 1120x630.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
gatorworld
post Jun 14 2022, 05:49 PM
Post #3





Group: Members
Posts: 4
Joined: 8-April 22
Member No.: 28,310



QUOTE(pandy @ Jun 14 2022, 04:31 PM) *

100% height doesn't work the way you think and even if it did the clip would be distorted.

Stick to pixels and keep the original aspect ratio. The size google suggests is that's 560x315 so you could use for instance 1120x630.


I got it to work with this html and CSS, added another div

<div class="iframe-container">
<iframe max-width="100%" max-height="auto" src="https://www.youtube.com/embed/wvNH28d3NN8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

---

.iframe-container{
margin-top: 30px;
position: relative;
width: 100%;
padding-bottom: 56.25%;
height: 0;
}
.iframe-container iframe{
position: absolute;
top:0;
left: 0;
width: 100%;
height: 100%;
}
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th April 2024 - 09:52 AM