Created
September 19, 2018 19:55
-
-
Save productioncoder/06717da101483af458865496dcf28120 to your computer and use it in GitHub Desktop.
Youtube Video dynamic resizing with CSS only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Rest unchanged */ | |
return ( | |
<div className='video-container'> | |
<div className="video"> | |
<iframe className='video-player' src={embedUrl} frameBorder='0' | |
allow='autoplay; encrypted-media' allowFullScreen title='video' /> | |
</div> | |
</div> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.video-container { | |
position: relative; | |
width: 100%; | |
&:before { | |
content: ""; | |
display: block; | |
padding-top: 56.25%; // 9 / 16 in percent | |
} | |
.video { | |
position: absolute; | |
top: 0; | |
left: 0; | |
bottom: 0; | |
right: 0; | |
.video-player { | |
min-height: 480px; | |
width: 100%; | |
height: 100%; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment