Last active
July 21, 2019 05:51
-
-
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
This file contains hidden or 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 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