Can I have a parent scroll container ignore overflow:visible content? - html

I'm creating an HTML page which is comprised of two sections; header and body. Rather than use a position:fixed header and allowing the whole page to scroll, I have used a normal header and made the body a scroll container. This is because there are fixed/sticky elements in the body which need to stick to the bottom of the header (and also due to problems with dynamic sizing of the header and body). The problem is that we have various UI elements which appear smooth across the header/body boundary. Our application's layout is responsive to screen size, and now the body may have a scrollbar, but the header doesn't, so they don't quite line up.
I have fixed this problem by having the body elements have a reduced width, and then using a position:absolute background div at the end, to overlap where the scrollbar would go, with the same background colours as the main UI element so they appear to be part of it. This means the header and body would keep a consistent width regardless of scrollbar.
The basic issue with this solution is that when the vertical scrollbar is shown, the browser also shows a horizontal scrollbar so that the user can "see" my placeholder background div, even though it doesn't occupy any of the width. I've tried a few different values for stuff like overflow, etc, but what it really boils down to is that none of them can show the placeholder divs when the scrollbar is not present without making a mess when it is present. There doesn't seem to be a CSS property for when the scrollbar is shown so that you can change the CSS as needed.
I've looked at e.g. scrollbar-gutter but we can't really use this as we need to continue supporting Chromium 88 as well as Firefox, iOS Safari, and similar. overflow:overlay would be ideal but isn't a well supported feature.
Some have suggested a mix of position:relative and position:fixed, but if I apply the right styles to get the element into the right place when there is no scrollbar, then it still causes the same issue when there is one.
Please see the following snippet (I tried the inbuilt one but it doesn't seem to work super well with content that requires scrollbars and such). I've created simple fixed-height divs to demonstrate the different content that I'm dealing with right now. The blue boxes should appear to go all the way across but don't need interaction right on that last bit. The red and green boxes should always line up, even though their layout is width-dependent and only the bottom section of the page scrolls if you shrink it down. These goals are achieved but when you shrink the page so that the vertical scrollbar is needed, the horizontal scrollbar also appears.
<html>
<head></head>
<body style="height:100vh;display:flex;flex-direction:column;margin:0">
<div style="height:200px;flex-shrink:0; max-width:calc(100vw - 17px)">
<div style="height:100px;background:blue; width:100%; position:relative">
<div style="position:absolute;width:17px;right:-17px;height:100%;background:blue"></div>
</div>
<div style="height:100px;background:red;margin-left:200px; width:50%"></div>
</div>
<div style="flex-grow: 1; overflow: auto;">
<div style="max-width:calc(100vw - 17px)">
<div style="height: 100px;background:green;margin-left:200px; width:50%"></div>
<div style="height: 100px;background:blue; width:100%; position:relative">
<div style="position:absolute;width:17px;right:-17px;height:100%;background:blue"></div>
</div>
</div>
</div>
</body>
</html>

Related

controlling width of fixed position elements with width:100%

I'm wrestling with two unruly elements - a navigation menu and background bar (kept separate to deal with an opacity issue). Their positions are fixed so they stay visible during scroll. Their widths, which should mimic their parent's, is set with a 100%. Unfortunately, when the window is stretched narrow enough their width extends outside of the parent.
This is a diagram of the html:
<html>
<body>
<content>
<nav-bar>
<nav-menu>
...
</content>
</body>
</html>
Showing should be easier than describing, so here's a link to the page:
http://www.seanoneill.us/test/index.html
When the browser is stretched beyond the max-width of the content, everything looks fine. When the browser is made narrow, the right end of the nav-bar and nav-menu breaks out of the content width. In other worts, the right edge of "Contact" should be inset from the right edge of the content div by 20px of padding. The best way to see this is to scroll down a big so the menu covers an image and the semi-opaque nav-bar is visible. Then stretch the browser to the max-width of the content and wiggle it back and forth over that threshold.
Can anyone tell me how to keep the nav-bar and -menu inboard of the content div?
I've held off listing any of the css here since there are a handful of elements involved and I have no idea which is the critical one. I'm hoping it's acceptable to just post a link.
Thanks so much for reading.
You have content { min-width:700px }, and with your nav floated right, it will stay there.
If you can remove the min-width it will fix itself, or you can move .nav-manu outside of the .content container and, if you don't wrap it with something else that has min-width, it will honor the width of the body/window

How do I force scroll bars in a fully responsive site?

I am currently helping a friend with a very simple, responsive 1-page site which can be viewed here.
If you drag your browser window down to about 450px in width or less, you will see that the layout changes which is correct. However, when you drag vertically to make the page shorter, the content in the middle gets hidden/covered.
I need for the text in the middle to always be visible, even if the user needs to scroll/swipe to see it. NOTE: It is the whole body that I would want to scroll, not just the content div.
In this image, you can see that the text is covered if the viewport isn't very tall:
On the div that contains the main content, I have tried setting height and min-height as well as using !important to no avail.
I must be missing something obvious. Any help is appreciated.
Set the div named "content" the style: "overflow-y: scroll;"
<div id="content" style="overflow-y: scroll;">
<!-- content -->
</div>
body {
overflow-y: scroll;
}
Updated to be the whole document.

Twitter bootstrap full width panels being trimmed

I am working on a fixed width page using bootstrap and I noticed when testing it on iPhone the full width header and footer background were clipped to 70% of the width.
It's Business marketing type site, frequented by people looking for a supplier, normally from their office PC so the responsive aspect was not a requirement but I digress.
Back to the problem
Viewing on a full size screen it looks as it should but if you scroll smaller than the limits of the container class (940px in this case) and then scroll back a little you can see the background has trimmed.
I have been tinkering with it for a while to the point where I have stripped everything out and just put in a simple bunch of nested divs to test and make sure the issue is not some rouge tag but it still does exactly the same thing.
I think the issue is related to items that are not wrapped in the class of container but if I need a full width panel and 940px fixed content I am not sure how I am going to achieve it with bootstrap.
// This Fails
<body>
<header class="fullwidth">
<div class="container">
<p>The content</p>
</div>
</div>
</body>
// This is fine but not full width
<body>
<header class="container">
<p>The content</p>
</header>
</body>
I have not adulterated bootstrap if I remove it or my styles together and restyle the body manually it goes away. But it seems to be a cumulative issue...
Anyone come across this before?
I don't really want to have to strip bootstrap out if possible.
As requested I have appended the link:
http://jsfiddle.net/NcZFz/3/
If you notice in jsfiddle whatever size your viewport is the header will fill it, but the view port only. And if you are using a MAc and have a magic mouse (or whatever) you can scroll right in that view port to see white. But this is supposed to be edge to edge so there should be no white.
It appears you have a margin on the <ul id="menu-primary-navigation">
#menu-primary-navigation { margin-left: 0; }
And you should also put .clearfix on the same element (because children are floating)
<ul id="menu-primary-navigation" class="clearfix">
Check this working jsfiddle.
All the above fixes could be avoided if you used the .navbar .nav classes (and associates) : read the doc.

Horizontal Scroll issue on website

On my site:
http://madlov.com/qa
I'm noticing that, if I hold the right arrow key... or click and move the mouse to the right (anywhere on the page), there is a bunch of space to the right... the pages scrolls, although I've turned off scroll bars with:
overflow-x: hidden
how can I control this behavior or at least understand which element is causing the horizontal scroll.
your should really get rid of your overflow hidden on the body... what if by browser is jsut to small to show the entire website?
the problem is div.grid_8.prefix_3.suffix_5 (the one next to the facebook like button) it has a padding right, that pushes the max width of your site
remove the 400px padding-right and the overflow on the body. Then everyone is happy, you because you have no horizontal scroll-bars and people with small resolutions or sight problems...
You could find this out by your own by removing the elements from the DOM one by one in your favorite debugger/inspector (firebug for example)
There is one over-sized div that's causing the problem. Its location is:
<html>
<body>
<div class="nav-bot-wrapper sm-shadow">
<div class="logo container_12 clearfix">
<div class="grid_8 prefix_3 suffix_5">
There is too much padding-right in the .container_12 .suffix_5 class (960.css, line 327)
You do not turn off scrollbars, you just hide overflow and so there are none of them.
In your code look for elements with fixed width; padding or other parameters that might cause this problem.

Scrollbar problems in IE

I have a fixed-width content area using margin:0 auto to keep it centered and a repeating background that fills the whole page. Nothing should cause the browser to use a horizontal scrollbar, unless the browser is less than browser is less than the fixed-width content. In IE however, a horizontal scrollbar is present and allows me to scroll slightly to the right which displays a 'gap' that appears to be the width of the vertical scrollbar. Curious as to why this is happening.
I have searched far and wide and found people with similar problems, but most discussion is regarding tables or other specific elements causing the problem that are not present on my page.
See link for example, open in IE8 and scroll right. Any help is appreciated.
http://finchsbrasserie.com/test_new_site/
Why don't you set the div css propety as overflow-x:hidden