What I am trying to do is to hide the scrollbar of a DIV. In order to do that, I created an outer DIV with overflow-y: hidden;
and placed a slightly wider DIV inside it.
I gave the outer DIV higher z-index
than the inner one.
Both have position: fixed;
, but no matter what, it doesn't work – the wider DIV is still visible outside its parent DIV.
I also made it so that z-index
of html
would be higher than that of the inner DIV, in hopes it would hide the scrollbar, but that didn't work either. Neither did using negative z-index
work.
I've searched for days for a fix to this but none worked.
Here is the basic example code(should I include the entire code in jsfiddle?) - HTML:
<html>
<body bgcolor="#BFBFBF">
<div class="outer_MB">
<div class="in_MB">
</div>
</div>
</body>
</html>
CSS:
html {
z-index: 2;
}
.outer_MB {
position: fixed;
height: 70%;
width: 84%;
left: 8%;
bottom: 0;
border-left: 1px solid black;
border-right: 1px solid black;
overflow-y: hidden;
z-index: 2;
text-align: center;
}
.in_MB {
height: 70%;
width: 86%;
position: fixed;
overflow-y: scroll;
z-index: 1;
}
PM: This is the first question I asked on this website, so tell me if I'm missing something and I'll try to fix it.