I have read this question & answer: CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue as well as a bunch of other conflicting use cases. I've tried applying different overflow types to different parents also. Nothing seems to get my use case working.
My Case
I have a full height fixed menu that will contain lots of links so if a browser isn't high enough to show them all I'd like to allow the user to scroll within the fixed div. Not a bold request.
How do I work around this issue, here's an example of the setup i'm using: http://jsfiddle.net/mz9abf43/9/
UPDATE
This is the updated fiddle with my full code for context, this is exactly how I want my menu to look but I just want to allow vertical scrolling if the screen height is smaller than the length of the menu. http://jsfiddle.net/mz9abf43/24/
Expected Output
The lines between each link should overflow to the right of the blue menu (like the image below) AND also allow the user to scroll within the blue menu. Currently I can only do one or the other.
My structure is:
<div id="fixed">
<nav>
<ul class="menu">
<div class="drop">
<li>Link here</li>
<li>Link here
<ul>
<div class="drop">
<li>Link here</li>
<li>Link here</li>
</div>
</ul>
</li>
<li>Link here</li>
</div>
</ul>
<nav>
</div>
My CSS is
#fixed {
width:280px;
position: fixed;
top: 0;
left: 0;
bottom:0;
z-index: 1000;
background: #fff;
}
.menu {
padding: 0;
margin: 0;
position: fixed;
z-index: 9998;
top:0;
bottom:0;
left:0;
background: white;
width: 280px;
/* THIS IS NOT WORKING - HOW CAN I GET THIS WORKING? */
overflow-y: scroll;
overflow-x: visible;
}
.menu .drop {
background: #fff;
height: 100%;
z-index: 0;
}
To make an element stick to the screen when you are scrolling, select it and just click the Fix Position When Scrolling checkbox. Select the artboard, set a Vertical Scrolling and set a value for the Viewpoint Height that's lower than the height of the entire artboard.
The overflow-y property specifies whether to clip the content, add a scroll bar, or display overflow content of a block-level element, when it overflows at the top and bottom edges.
Position:fixed can't be scrolled. When you set it with top:0 You are positioning the element to be always at the top of the window (not the container) and I'm afraid that's exactly what you will see, your ul always at the top of the window.
Probably better to use an absolute positioned if your menú may get many elements so you will get scroll bar on the body.
so as a starting point is You just need to chnage fixed for absolute and delete the bottom:0
property:
.menu {
padding: 0;
margin: 0;
position: absolute;
z-index: 9998;
top:0;
left:0;
background: white;
width: 280px;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
as in this FIDDLE
You now just need be sure the height of this menu is as "tall" as your content so it will fill all your window height. You can use a basic jquery:
var menuHeight = $('.content').outerHeight(true );
$('.menu').css({
'height': menuHeight + 'px'
});
where you calculate the height of your "content" container and add it as a css property to your menu:
JSFIDDLE2
Note: I made this answer from my comments on the question. If you find any other problem feel free to comment here and I'll try my best to help (if I know how).
You should use box-sizing:border-box
in .menu li a
and make width: 70%;
in .menu .drop
.
.menu li a {
color: #aaa;
text-transform: uppercase;
font-size:12px;
padding: 8px 35px;
display: inline-block;
width: 100%;
border-bottom: 2px solid #f0f0f0;
box-sizing:border-box;
}
UPDATE Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With