Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding border-radius for embedded YouTube video

Tags:

Please see this fiddle. Notice instantly before loading the border-radius works fine. A few milliseconds later the rounded corners disappear.

How can I add rounded corners to embedded YouTube videos?

like image 656
Randomblue Avatar asked Oct 18 '11 18:10

Randomblue


People also ask

How do you code border-radius?

CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.

Can you add border-radius to outline?

No. Borders sit on the outside of the element and on the inside of the box-model margin area. Outlines sit on the inside of the element and the box-model padding area ignores it.


1 Answers

This is very simple using CSS3. All you guys are missing out is the z-index which is playing bad cop.

Look at the code below, I wrapped the player in a div, set it's height and width as I like, set overflow to hidden and z-index as required. Border radius works pretty awesome!

.player {    border-radius: 10px;    overflow: hidden;    z-index: 1;    height: 320px;    width: 480px;  }
<div class="player">  <iframe width="480" height="320" src="https://www.youtube.com/embed/aiegUzPX8Zc" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>  </div>
like image 87
Sibidharan Avatar answered Oct 07 '22 04:10

Sibidharan