I have two 50% width columns template - with 700% and 200% of height. 200% column is sticky bottom, so I can always see it.
But if I scroll to the bottom of the page and start scroll up - right column will not be scrolling. It will start scrolling only when I get up to 200% of page top.
Is it possible to scroll right column always when it end?
For example, if I scrolled to end of page (or more than 200% height) and start to scroll up - I want to scroll to the right column too.
Example:
codepen.io
The common methods to disable scrolling in Javascript are:
Force scroll the user back to a specific spot or element
window.onscroll = () => { window.scroll(0, 0); };
Hide the overflow (no scrollbars)
document.body.style.overflow = "hidden";
Show the content in a fixed full-screen container
<div style="width: 100vw; height: 100vh; position: fixed; top: 0; left:0; z-index: 999"></div>
Related
as you know if html content vertical view is more than browser window, a vertical scroll bar will add to page. It will cause moving html content into left which does not have a good view.
You can avoid this treat using this CSS code:
html{
overflow: scroll;
}
But there is a problem with this code, you will always see a disabled scroll bar on right side of the page. Now let's check another way, in this way you will subtract body width of the scroll width:
body {
width: calc(100vw - 68px);
margin-left: 34px;
}
This will put body in center and if in future a vertical scroll bar add to the page, it won't affect content and will be on the right side out of the body area! This way is good but there is a very little problem. you have subtracted your body width!!! Just think I have a fully filled body area! In this situation I need the whole 100% width and also I do not want the scroll bar to move my content into left and also I do not want to see a disabled scroll bar always!
So I'm looking for a way I can make scroll bar while showing on top of html content. so Nothing will move and also I have 100% width and when ever it is needed I will see scroll bar.
Is there such trick? Hope I'm clear enough.
Ok so I want a specific div to stay in the corner of my html5 web page even when i scroll down.So it is just hanging in the corner so wgeb you scroll down the age it is still in the corner. Not in a fixed position, but stuck to your screen kind of. I want these divs to stay in the upper right corner even when I scroll it stays there.
<div style="font-size:50px; color:brown;" id="allCount">0</div>
<div style="font-size:30px; color:brown;" id="apsCount">0</div>
That's exactly what position: fixed is about.
#cornerItem {
position: fixed;
top: 0;
left: 0;
}
Try a little demo: http://jsfiddle.net/4zjym/ There is a gradient under the fixed element to show you, that you can actually scroll the content under the item.
I have a custom timeline view like this: http://jsfiddle.net/B4xRb/1/
The inner vertical scroll affects the rows beneath the header only.
The parent horizontal scroll affects the entire timeline.
<div class="parentDiv">
<div class="monthHeader"></div>
<div class="lanes"></div>
</div>
However, how could I structure this so that the vertical scroll bar can be seen WITHOUT
adjusting the row data as it can be really wide.
initially scrolling to the right, I want it so as you load the page, both scroll bars are visible
Here's the solution I came up with, using jQuery: http://jsfiddle.net/eB8WQ/6/
First off, to hide the second outside vertical scroll bar, add this code
html, body {
overflow-y: hidden;
}
for .lanes, you want to hide the horizontal scroll bar and set the initial width to 100%.
width: 100%;
overflow-x: hidden;
Next, the javascript you want to use sets the width of .lanes to 100% while scrolling (to avoid the messy flickering problem), and when you're done scrolling, it calculates the position of the horizontal scrollbar and adds that value to the width of your body element. Use the $.data function to store the value.
More information on $.data: http://api.jquery.com/jQuery.data/
$('.parentDiv').scroll(function() {
$('.lanes').css("width", $('.monthHeader').width());
});
$('.parentDiv').scroll(function() {
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
$('.lanes').css("width", $('.parentDiv').scrollLeft() + $('body').width() + "px");
}, 100));
});
Some code taken from this previous answer.
If you take a look at: http://www.bendemeerwoolshed.co.nz
I have a fixed header. All fine there, however, if you reduce the width of the window (or look at it zoomed in on a mobile device) and need to scroll on the X axis, only the content scrolls. Is there a way to set position: fixed for just the Y axis?
Here is the CSS for the header:
header#header {
position: fixed;
height: 188px;
background: #fff url(../images/headerbgstrip.png) bottom center no-repeat;
width: 100%;
}
Taken care of with a simple piece of jQuery:
$('#header').css("left","-"+$(window).scrollLeft()+"px");
As a side note, I attached the header to the content in mobile devices as the static header was occupying too much real estate in mobile browsers anyway.
I'm trying to make the main body of my site to have a fixed height (I think!).
Anyway, the site body is just white, with a border of size 1. Basically, the size of the body is determined by what's in it so, for example, it will resize automatically as more things are added.
What I want is vertical scroll bars so the body doesn't extend forever (is that right?). Should I have a fixed body size?
If you want vertical scroll bars you can use this in your CSS;
body {
height: 900px;
overflow-y: scroll;
overflow-x: hidden; /* hides the horizontal scroll bar */
}
What are you trying to accomplish? You sound unsure if you even want the scroll bars; is there a reason you want to show the scroll bars instead of just having the browser handle the scrolling when the content gets larger than the window?
Yes. You need a fixed height
body{
height: your-height;
overflow:auto;
}
will generate scroll bars only when you overflow the area without growing it vertically.
So, in your body create a layer:
<div id="mainbar">
</div>
And using CSS you can set the height:
div#mainbar {
min-height:100px;
overflow:auto;
}
The min-height guarantees the initial height that you need. Once it goes over that, it you will automatically have scrollbars. If you would rather the page itself scroll and the body lengthen, just take out the overflow line from the CSS.
If you want the vertical scroll bars to an inner div on your site (like so you can have a footer visible at all times), simple specify the height of the div:
#inner { max-height: 300px;
}
I think the default for the overflow is to scroll, but if your content is cutting cut off with no scrollbars, you could also set
overflow: auto;