SO 47230444
https://stackoverflow.com/questions/47230444/change-style-of-div-with-specific-class/47231570#47231570
by jfcandidofilho
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div id="menudd" class="show">
<a href="index.html">Home</a><br />
<a href="aboutme.html">About Me</a><br />
<a href="shotterm.html">Short-Term</a><br />
<a href="middleterm.html">Middle-Term</a><br />
<a href="longterm.html">Long-Term</a><br />
</div>
CSS
#menudd {
padding: 0.5em;
position: fixed;
overflow: hidden;
max-height: 0px;
opacity: 0;
width: 200px;
border-radius: 10px;
box-shadow: 0 0 35px 15px black;
transition: all 1s ease;
}
#menudd.show {
opacity: 1;
}
JavaScript
var menu_dropdown = document.getElementById("menudd");
var menu_item = menu_dropdown.getElementsByTagName("A");
menu_dropdown.style.maxHeight = menu_item[0].offsetHeight * menu_item.length + "px";