Last active
September 6, 2017 10:13
-
-
Save viktorViktor/a37abe0a55e977a5c20c to your computer and use it in GitHub Desktop.
jQuery 16:9 (Set container to a fixed but dynamic-width 16:9 ratio)
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
<div class="sixteen-nine"></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
// set aspect ratio to 16:9 | |
var sixteenNine = function(){ | |
var width = $('.sixteen-nine').width(); | |
$('.sixteen-nine').css('height',width * 0.5625 + 'px') | |
var height = $('.sixteen-nine').height(); | |
// print out values | |
$('.sixteen-nine').html(width + " x " + height); | |
}; | |
// on page load | |
$(document).ready(sixteenNine); | |
// on window resize | |
$(window).resize(sixteenNine); |
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
// no need for css, but it's prettier this way! | |
html, body { | |
margin: 0; | |
height: 100%; | |
width: 100% | |
} | |
.style { | |
margin: 0; | |
padding: 10px; | |
color: white; | |
-webkit-font-smoothing: antialiased; | |
font-family: "Helvetica Neue", sans-serif; | |
font-weight: 100; | |
background: #f7464a; | |
font-size: 100px; | |
@media all and (max-width: 630px) { | |
font-size: 72px; | |
} | |
text-align: center; | |
max-width: 100%; | |
width: 100%; | |
} | |
.sixteen-nine { | |
@extend .style; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment