Created
August 12, 2019 19:40
-
-
Save charisTheo/d21a8b05b30fc1271e6393304923b2b0 to your computer and use it in GitHub Desktop.
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
| var list = document.getElementById('list'); | |
| var listItems = Array.from(list.children); | |
| for (var i = 0; i < listItems.length; i++) { | |
| var listParentHeight = list.parentElement.offsetHeight; // No-No: calculate parent height in every loop | |
| listItems[i].style.marginTop = Math.floor( listParentHeight / listItems.length - 10) + 'px'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment