Elements collapsing onto each other due to display:none; during js formatting