Skip to content

Instantly share code, notes, and snippets.

@estysdesu
Last active July 21, 2019 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estysdesu/dd05e0670631c167759d32021e71d25d to your computer and use it in GitHub Desktop.
Save estysdesu/dd05e0670631c167759d32021e71d25d to your computer and use it in GitHub Desktop.
[JavaScript: resize all elements of a HTML tag] This sets height = width #resize #js #html #dom
function updateSize() {
var projectTile = document.querySelectorAll("#projects .tile.is-child");
projectTile.forEach( function(tile, index) {
if (window.innerWidth > 768) {
tile.style.height = getComputedStyle(tile).width;
} else {
tile.style.height = null;
}
})
}
window.onload = updateSize;
window.onresize = updateSize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment