Skip to content

Instantly share code, notes, and snippets.

@maciejkorsan
Created March 6, 2017 23:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejkorsan/ae65eeb5afc3121eea5d183d75f64098 to your computer and use it in GitHub Desktop.
Save maciejkorsan/ae65eeb5afc3121eea5d183d75f64098 to your computer and use it in GitHub Desktop.
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