Last active
December 28, 2015 20:49
-
-
Save willbroderick/7560228 to your computer and use it in GitHub Desktop.
Scale size of text up/down with % to sit nicely inside parent container. Great for live-type over images/slides.
- CURRENTLY DEPENDENT ON A BASE SIZE FROM: {{ settings.adv_page_width }}
- how should this be remedied? What's the best way to get a 'default' size? Maybe just a px val in data attribute?
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
<script> | |
$(function(){ | |
//Text that scales up/down based on container width | |
function resizeScalingTextFromColumn() { | |
$('.scaled-text').each(function(){ | |
var $base = $(this).closest('.scaled-text-base'); | |
var scale = $base.width() / {{ settings.adv_page_width }}; | |
$(this).css('font-size', (scale * 100) + '%'); | |
}); | |
} | |
$(window).resize(resizeScalingTextFromColumn); | |
//Note: Use debounced-resize if available | |
}); | |
</script> | |
<div class="container"> | |
<div class="column-size-class scaled-text-base"> | |
<h1><span class="scaled-text">I HAVE THE POWEEEEER</span></h1> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment