I would like to create a side navigation menu. That is visible on large screens and hidden on small screens and becomes visible when the javascript function is called to unhide it.
Everything is working as expected, however the content is not hiding even after setting the width to 0; the text is still visible.
@media screen and (max-width: 768px)
{
.mysidebar
{
height: 100%;
width: 0px;
position: fixed;
z-index: 15;
top: 0;
left: 0;
background-color: #405a84; /
overflow-x: hidden;
padding-top: 10px;
transition: 0.5s;
padding-right: 0px !important;
padding-left: 0px !important;
text-overflow : hidden;
}
}
@media screen and (min-width: 768px)
{
.mysidebar
{
width : 16%;
height : 100%;
display : inline-block;
float : left;
}
.rightmainpane
{
width : 84%;
height : auto;
display : inline-block;
}
}
<div class="mysidebar" id="mySidenav">
Some sample content that is not hiding on small screen as expected, but the
background color etc are hiding.
</div>
<div class="rightmainpane" id="rightmainpane">
Some ok content that should be visible
</div>
Using this javascript code to hide / display the id="mySidenav" div
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("mySidenav").style.width = "0";
setting the display : none/block is resolving the issue. However it is not showing transition , the showing and hiding transition is quite important for me.
Please help. Thank you.
display: none
? – Discomposebackground-color: #405a84; /
Removing that backslash causes theoverflow-x
to hide the element, as intended. – Precaution