I want my sidebar to have spacing from top equal to header's height. When I use clientHeight
in js, although it returns the right value when I print it via alert()
, it doesn't apply to other elements as marginTop
or top
value. (Position
was included while using top
).
HTML
<body onload="sidenav_height()">
...
</body>
JS
function sidenav_height(){
var height = document.getElementById("header").clientHeight;
document.getElementById("sidenav").style.marginTop = height;
}
Aucun commentaire:
Enregistrer un commentaire