I have 3 divs with scrollbar. if we move one scrollbar and it reaches end of scrolling area page also scrolls.
I want to fix this issue.
Fiddle for it. http://jsfiddle.net/78h8e88x/2/
html, body {
height: 100%;
position:relative;
}
body
{
line-height:100px;
text-align:center;
}
.left
{
position:absolute;
margin-left:5%;
margin-top:3%;
display:block;
height:80%;
width:20%;
overflow:auto;
}
.center
{
position:absolute;
margin-left:25%;
margin-top:3%;
display:block;
height:80%;
width:50%;
overflow:auto;
}
.right
{
position:absolute;
margin-left:75%;
margin-top:3%;
display:block;
height:80%;
width:20%;
overflow:auto;
}
if we move one scrollbar and it reaches end of scrolling area page also scrolls.
The body element gets a margin of 8px by default (in Chrome at least). In the case of your fiddle this makes the content slightly bigger then the window and thus a scrollbar appears. Setting the margin to 0 on the body will remove this scrollbar. See jsfiddle: https://jsfiddle.net/vbvmLbmq/
That of course only fixes the scrolling behaviour in your fiddle which was a matter of window size. You can prevent scrolling on the html,body elements entirely by adding the overflow: hidden; css rule to them but keep in mind that would also hide any elements that flow past the height of those elements.
Continuing the scrolling of the page after a child elements scrolling has reached its end is browser application behaviour, which you cannot influence with javascript on your page.
Related
In my web app I want to have a fixed div modal which occupies the whole screen, however this modal's scrollbar is not visible, instead only the body scrollbar is visible. I assume my fixed div scrollbar is right behind the body scrollbar, this makes it so I can only use arrow keys to navigate down while seeing the body scrollbar instead of fixed modal scrollbar.
.fixed_div{width:100vw; height:100vh; background-color:rgb(240,240,240); overflow-y:scroll !important; overflow-x:hidden; display:flex; flex-direction:column; position:fixed; top:0px; left:0px; bottom:0px; right:0px; z-index:99999999999999999999999999999999999999999999999999999999999999999999 !important;}
.body{margin:0px 0px 0px 0px; background-color:white; position:relative; display:flex; flex-direction:column; max-width:100%; min-height:100%; height:auto; overflow-x:hidden;}
You have to set the height of the .modal-body in and give it overflow-y: auto. Also reset .modal-dialog overflow value to initial.
So I'm trying to design a webpage and was trying to get the footer to stick to the bottom of the page at all times. I did manage to do that with trouble but I figured out where my error was. What I want to know is what is the difference between doing this,
body {
background: red;
margin:0;
padding:0;
height:100%;
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background: black;
padding:10px;
}
#content {
background: green;
padding-bottom:100px; /* Height of the footer element */
}
#footer {
background:#ffab62;
width:100%;
height:100px;
position:absolute;
bottom:0;
left:0;
}
and doing this,
html,
body {
background: red;
margin:0;
padding:0;
height:100%;
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background: black;
padding:10px;
}
#content {
background: green;
padding-bottom:100px; /* Height of the footer element */
}
#footer {
background:#ffab62;
width:100%;
height:100px;
position:absolute;
bottom:0;
left:0;
}
Why does putting the html part at the top make the footer part of the code work? It doesn't seem to effect any of the other code, just the part that makes the footer stay at the bottom. This isn't my code just the code I got from here I have the same issue in my code though and was just wondering what the deal was cause I can't find anything on this.
http://www.cssreset.com/2010/css-tutorials/how-to-keep-footer-at-bottom-of-page-with-css/
Sorry if I wrote this wrong first time posting.
Body looks to its parent (HTML) for how to scale the dynamic property, so the HTML element needs to have it's height set as well.
the absolute position must be relative to another element and in your case the footer is relative to the body. By default the height of body and html isn't 100% to the screen, so if you make your footer absolute to the bottom of body it will be at the bottom of body not the screen so to solve this you made the body height is 100% of the html which must be also 100% to the screen.
you can also use the fixed position instead of absolute, position:fixed will be relative to the screen not to any other element so you footer will be in the bottom even the body and html height isn't 100%
I am converting an html page to a responsive page with a #media query without any framework.
Whenever I resize my browser window to a lower width, the divs are overlapping with each other.
First, I was using position:absolute;
but now I have removed position:absolute; but the divs are still overlapping with each other.
.demoD
{
width:100%;
position:relative;
display:flex;
margin-top:50%;
}
#demoD1 {
width:50%;
padding:40px 10px 20px 40px;
}
#demoD2{
width:50%;
background-color:#F3F6F7;
padding:80px 10px 30px 40px;
}
divD2 is overlapping with divD1. Both divD1 and divD2 are placed in divD.
Please give me some solution.
I've been working on making a drop-down menu that has a max-height, and puts vertical scrollbars on the element if it exceeds it. For some reason, when this vertical scrollbar is added, the width does not automatically adjust to compensate for the width of the vertical scrollbar, and creates a horizontal one as well.
Here is a fiddle so you can see a simplified version of my problem. Anyone have a good solution (besides setting a width on it, because I want it to adjust to the content inside, and preferably no JavaScript)?
.wrapper { display:inline-block; max-height:200px; overflow-y:auto; background:#f00;}
.wrapper > a { display:inline-block; padding:20px; white-space:nowrap; }
You can use overflow-y:scroll.
.wrapper {
overflow-y:scroll;
overflow-x:hidden;
}
Fiddle: http://jsfiddle.net/4e00dp7w/2/
Note that overflow-x:hidden is not really needed, but just in case.
When the vertical scrollbar is added, it will take some space from inside the container, in this case .wrapper. To avoid this, you can add overflow-x: hidden to your .wrapper. class like this:
.wrapper {
display:inline-block;
max-height:200px;
overflow-y:auto;
background:#f00;
}
However, as i said, it takes space from inside the container, so your content may be overlayed by the scrollbar. A workaround to this problem is adding a little padding to your .wrapper class to compensate this space ocupied by the scrollbar.
.wrapper {
display:inline-block;
max-height:200px;
overflow-y:auto;
background:#f00;
overflow-x: hidden;
padding-right: 10px;
}
Working sample: http://jsfiddle.net/4e00dp7w/7/
I would set...
.wrapper{
overflow-x:hidden;
overflow-y:auto;
}
that way a scroll bar will only show if the inner content is taller than the wrapper.
My problem is that I have a web page with a footer. I would like the page to extend the footer to the bottom of the browser window if there is not enough content to fill the entire page. I would also like the footer to go to the very bottom of the page when the content exceeds the height of the browser and there is a vertical scroll bar.
For some reason I cannot get this to work, I followed the tutorial on this page: http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
and the tutorial specifically says it does what I want-
"On long pages with lots of content the footer is pushed off the visible page to the very bottom. Just like a normal website, it will come into view when you scroll all the way down. This means that the footer isn’t always taking up precious reading space."
When I follow the tutorial it successfully puts the footer on the bottom of the page when there is not enough content to fill the page, but when there is more than enough content the footer is prematurely placed where the browser window initially ends because the body's and the everything container's heights are set to the height of the window as opposed to the height of the entire page (height of page with with scrolling).
the div organization is as follows:
<div class="everything">
<div class="main_content"></div>
<div class="template_footer"></div>
</div>
My CSS code:
html, body {
margin:0;
padding:0;
height:100%;
}
.everything{ //main container
width:100%;
min-width:960px;
max-width:1450px;
margin-left:auto;
margin-right:auto;
min-height:100%;
position:relative;
}
.main_content{ //body container
width:100%;
position:relative;
float:left;
}
.template_footer{
width:100%;
height:44px;
background-color:rgba(0, 0, 0, .5);
position:absolute;
bottom:0;
}
I've also tried a bunch of different variations with height and nothing works correctly, I've searched through other questions and they don't seem to answer this problem specifically.
The footer is absolute positioned to the bottom of the .everything container.
So no matter the content, the footer will be covering the bottom 44 pixels of your container.
html {
margin: 0;
padding: 0;
height: 100%;
}
body {
min-height: 100%;
position: relative;
}
.main {
padding-bottom: 60px;
}
.footer {
position: absolute;
text-align: center;
bottom: 0;
width: 100%;
height: 60px;
}
the main section padding-bottom should be bigger than the height of the footer. The footer section has to be position absolute. The whole page should be min-height 100%.