Scrollbar styling mysteriously changed - css

For some reason, the styling of my scrollbars changed.
I did not change any of the overflow styling (I am using overflow-y: scroll for my divs).
The scrollbar used to disappear when the div was not being scrolled, similar to the scrollbars used in the Facebook chat.
Now it has this static border and the scroll bar does not disappear:
I am using Chrome as my browser.

You can some some javascript which detects when user scroll then show scroll bar
here is a snippet
function scroll(e){
e.target.style.overflow='scroll';
}
function noscroll(e){
e.target.style.overflow='hidden';
}
document.getElementById('div').onwheel=scroll;
document.getElementById('div').onmouseout=noscroll;
div {
width:200px;
height:100px;
border:solid black;
overflow-y: hidden;
}
<div id="div">
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
This is a line
</div>

If you want the scroll bar to appear only when there is something to scroll in, use overflow: auto instead of overflow: scroll

One way is to create a custom scroll pane. Then it is easy to set the opacity of the scrollbar to zero when the mouse leaves it, something like
scrollpane.onwheel = function(){
scrollbar.style.opacity = 1;
};
scrollpane.onmouseout = function(){
scrollbar.style.opacity = 0;
}
Another way would be to hide the scrollbar with another element on top of it. You can create an outer div with overflow:hidden and an inner div with overflow:scroll. Then set absolute sizes for both divs and make the inner div about 20px bigger than the outer div. This should hide the scrollbar.
I'd like to add that it's hard to answer such a vague question. It would have been easier if you wrote your code into your question.
EDIT:
I have created a working jsfiddle with a custom scrollbar.
Custom scrollbars are a bit difficult because many events are involved, and they work differently in different browsers. For example, it might not work well on mobile devices. I have disabled text selection during dragging the slider, but this doesn't work the same on all browsers.
I even managed to prevent scrolling on the page while the cursor is in the custom scroll pane.
I hope that this meets your expectations!
Aloso

Related

Clicking on button shifts entire page a few pixels to the left

I'm trying to fix an issue where when a user clicks a button it causes the entire page to shift to the left. The issue only seems to appear when the browser is maximized.
You can try it yourself here: https://professionallyspeaking.oct.ca/exemplary.aspx
Click on the "Great Teachers- Alphabetical +" button to see the shift in action.
The page is adding a vertical scroll bar when the content height exceeds that of the browser window. It is default behaviour, but if the shift seems odd to you, the only way to "fix" it is to force the scroll bar on the <body> when the content doesn't fill the page, by adding the following css:
body{
overflow-y: scroll;
}
Page was shifting due to appearance of the vertical scrollbar. Thanks to #j08691 for pointing this out. I resolved the issue by applying overflow-y: scroll to the html:
html {
overflow-y: scroll;
}

dynamic bootstrap 3 navbar fixed top overlapping content

I found other questions that address a similar problem, but this is slightly different, as the top bar content is dynamically changed. That means I don;t know at which screen width the bar will begin overlapping content.
This CSS works at a standard resolution with the current top bar text. I know I can use #media (max-width) in CSS to adjust the padding-top, but that doesn't account for dynamically changing top bar text.
body {
min-height: 2000px;
padding-top: 70px;
}
Is there a way to check the top bar's height, and add an offset to the body without using Javascript?
Another, perhaps better, option is to switch the top bar to the mobile view whenever it gets too crowded for a single row. Any thoughts on how to do that?
Thanks
https://jsfiddle.net/waspinator/4c2yespy/7/embedded/result/
Original fixed top example.
EDIT:
updated jsfiddle with javascript fix https://jsfiddle.net/4c2yespy/8/
There is no way to do this wit css only, but you could use the javascript resize event to dynamically change the body padding top:
function adjust_body_offset() {
$('body').css('padding-top', $('.navbar-default').outerHeight(true) + 'px' );
}
$(window).resize(adjust_body_offset);
$(document).ready(adjust_body_offset);

CSS positioning change resulting from resizing brower window

I have one more problem to solve before I can call my first website done, and I would greatly appreicate the help of this community.
You can see my website for yourself at www.dylanbisch.com
The problem I am trying to solve occurs on the homescreen between the class artdesign and tumblr-wrapper.
Basically, the class "artdesign" contains the two circular buttons and the class "tumblr-wrapper" contains the black and white photos on the homescreen.
My problem occurs if you shrink the browers window and then try to scroll left and right. Instead of scrolling left and right across the entire page, only the black and white photos in the "tumblr-wrapper" class scroll left and right.
I am looking for a solution that would stop the tumblr-wrapper from being the only thing to scroll when the brower window is small, and would create full page left right scrolling.
I hope I have explained by problem adequately, but if I need to explain something differently please let me know.
On line 370 of style.css, you have a position:fixed applied to the .artdesign.
Im not sure what the logic was for putting it there exactly, but if you remove it, the page will scroll as you expect.
The fixed position means that div is fixed and will not move (even if you scroll), its mainly used to stick headers and footers to the top and bottom of pages. (Like the twitter bootstrap page [notice the black header menu along the top?.. thats fixed])
So basically:
.artdesign { /* Line 370 of style.css */
float: left;
padding: 200px 0 0 10px;
position: fixed; /* REMOVE THIS POSITION FIXED TO SCROLL! */
width: 579px;
list-style-type: none;
}
You have .artdesign set to "position: fixed" so this will always stay at the same window location. Change this to "position: absolute" and this should solve the problem.

Getting div to run to the right side of the screen

Basically i'm trying to get a divider to run to the right edge of the screen (without overflow).
If you look here: http://gomysites.com and scroll down to the twitter section you will see i've set the twitter panel to run off to the left edge of the screen (no matter the size).
Now i want to do exactly the same on the right side. If you notice the grey divider between the blog posts id like this to run to the right edge of the screen (no matter the size) without it adding a horizontal scroller.
I've tried setting the css for the divider exactly opposite as i did for the titter panel:
.widget_gomy_news .divider{
margin:30px -10000px 30px 0;
background:#f3f3f3;
height:30px;
float:right;
width:610px;
padding:0 10000px 0 0;
}
But it adds a horizontal scroller. So i did try adding overflow:hidden; to the body. Which removes the scroller but i can still scroll everything left and right with the mouse.
Anyone got any ideas how i can achieve what i'm after? or will i need to use some js to make this work?
Thanks in advance.
Just remove the -10000px right margin and the 10000px right padding and it works. What do you need that for?
Use overflow-x: hidden on the body element. This will prevent the horizontal scroll but may trip you up in older versions of IE - Tested in IE8 and Chrome.
Edit:
You could also write some jQuery to grab the Window viewport height/width like: $(window).height();, and size your entire page's "container" div accordingly. This will allow you to know what numbers you're working with for setting the negative/position margins in your "divider" hack.
I think i've sorted it. I wrapped all the page content inside a div and added overflow hidden to that (rather than body). This worked in everything except IE7, but i can do a simple work around for IE7. Thanks for all the replies, Jeff sent me down the right path thanks.

CSS Shift Downward

Can anyone tell me what is going on with this widget: http://davidbeckblog.com/notify/? The relevant CSS is mostly at the bottom of style.css.
Basically, the widget has 3 sections. On the left is the button, the middle is the text box, and the right is a spot for a progress indicator. When I add in the text box and the progress indicator, everything gets pushed down.
Those are inline elements and the vertical align is baseline by default I believe. Set the vertical align on all 3 spans to top, and then it looks like you need to specify margin-top:-3px on span.status and maybe apply 1px top margin to the notify me span.
Alternatively you could have floated all 3 with a clearing element.
This seems to fix it:
.notify-me input, .notify-me span {
vertical-align: top;
}
.notify-me input {
margin-top: 0.4ex;
}
(Try to avoid, fixed-pixel margins/padding, as these will more quickly bust when the user changes font sizes.)

Resources