Created
March 6, 2017 23:05
-
-
Save maciejkorsan/ae65eeb5afc3121eea5d183d75f64098 to your computer and use it in GitHub Desktop.
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
function scaleHeader() { | |
var scalable = document.querySelectorAll('.scale--js'); | |
var margin = 10; | |
for (var i = 0; i < scalable.length; i++) { | |
var scalableContainer = scalable[i].parentNode; | |
scalable[i].style.transform = 'scale(1)'; | |
var scalableContainerWidth = scalableContainer.offsetWidth - margin; | |
var scalableWidth = scalable[i].offsetWidth; | |
scalable[i].style.transform = 'scale(' + scalableContainerWidth / scalableWidth + ')'; | |
scalableContainer.style.height = scalable[i].getBoundingClientRect().height + 'px'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment