Extra space when scrolling using fixed height - html

I have a wrapper with elements inside that obviously I want to scroll when there are more elements than the box can hold. However when I scroll below the last word it has a large amount of excess space. I believe this may be caused by the fixed height. I have tried using max and min height but doesn't seem to fix it Preview

JSFiddle was choking on your code because you were double terminating your icons. I removed the double </i> and the code resolved fine on JSFiddle: https://jsfiddle.net/uwtcje0L/
With that said, the reason for your issue was pretty easily identified, you have 400px of padding on the bottom of div.communitieswrapper. Replace the CSS class you provided with the following:
.communitieswrapper{
border: 2px solid #eeeeee;
border-radius: 7px;
padding-top:10px;
z-index: 1;
position: relative;
height: 450px;
overflow-y: scroll;
overflow-x: hidden;
}
Fiddle with example: https://jsfiddle.net/uwtcje0L/1/

Related

min-height not working as expected

Given the following structure, I need level2 have a min-height without changing the structure. Further, I am not able to move the overflow: hidden to a different class (the example is simplified, it would affect a lot of other things). It works with px, but not with %. All other css properties can be changed.
I am aware of vh, which works exactly like it should. But I would love a solution with CSS2.
Fiddle
HTML:
<div id="level1">
<div id="level2">
<div id="heighter"></div>
</div>
</div>
body and html: height 100%
level 1: min-height 100%, overflow hidden
level 2: min-height 100%
heighter: height 200px
Edit: More informations about the overflow:hidden
I am using this for a offcanvas navigation. This is a place where I can't use max-width (right?). If I replace the overflow with the max-width, the layout gets recalculated and after that I am able to scroll the level2 on the x-axis (left and right). Same problem as here (click on Push-Menu-Left and then you are able to scroll the x-axis). What I am trying right now is preventing the x-axis scrolling and being able to use the min-height: 100% corretly.
In order to calculate min-height, div#level2 needs to refer to the height definition of its parent. In your code, div#level1 does not have a specified height. You an specify one like so:
#level1 {
height:100%;
overflow: hidden; /* This has to be here */
background-color: red;
}
WORKING EXAMPLE
EDIT:
Explicitly setting height on div#level1 (rather than setting min-height), you no longer need the overflow:hidden definition. Removing that allows the page to scroll when div#heighter expands beyond the browser's height.
(You mentioned that you need the overflow:hidden for other reasons. If possible, please edit your question to describe those reasons a bit more.)
#level1 {
height:100%;
background-color: red;
}
#level2 {
min-height: 100%;
background-color: lightseagreen;
}
#heighter {
height: 2000px;
width: 100px;
background-color: white;
border: 5px dashed black;
}
WORKING EXAMPLE
http://jsfiddle.net/b8uj75e5/3/
#level2 {
min-height: 1000px; /* Working */
min-height: 100%; /* Not working */
background-color: lightseagreen;
display: block;
position: absolute;
width: 100%;
}
IT LIVES.
I just messed around until it worked.

Why doesn't overflow: hidden work in this case?

In the bookmark_matrix in this fiddle
http://jsfiddle.net/sjD24/14/
I'm trying to hide content outside of the 500 px width
by setting
overflow:hidden
I'm not getting the desired effect as it wraps to the next line instead.
MDN Reference
The two examples I've seen show overflow working with vertical content, I'm not sure if this implies it does not work with horizontal content.
Please note that I do not want it to wrap. Perhaps that would have been a better title.
You have no height set, so the div's height expands as needed. There's no overflow.
You could do something like this:
#bookmark_matrix{
border: 1px dotted #222222;
padding: 5px;
width: 500px;
overflow: hidden;
height: 1em;
}

How do I stop the border from breaking apart when zooming in?

http://mistcave.com/temp/
Zoom into the page and scroll right. The 1px black border at the bottom of the header is cut off a bit short. How do I fix this issue?
put the border bottom property in your header div
also to note if you are using google chrome you can go to select elements and view the dimensions of each div which will help you trouble shoot in the future
Made a dirty hack. Tough it work flawlessly.
Demo Fiddle
#wrap {
width: 100%;
}
#header {
border-bottom: 1px solid #000000;
margin-bottom: -1px;
}
That doesn't really matter. Because the Border-bottom effect follows the size of your browser. No web users would zoom in and out pages except you.
It will also be fine in every screensize, just don't zoom it in and out.
That thing is fine every site has that problem too but it's not a big deal.
set the width of the #wrap in CSS to be 100%
OR simply do the following:
body
{
overflow-x: hidden;
}
.extendfull, .extendleft
{
padding-left: 3000px;
margin-left: -3000px;
}
.extendfull, .extendright
{
padding-right: 3000px;
margin-right: -3000px;
}
overflow-x: hidden prevents horizontal scrolling, and increasing the padding is pretty self explanatory.

Can someone explain me why isn't <article>'s size correct and how to fix it?

http://zergxost.com/test.html
As you can see, if there's not enough text, the bottom gray line goes way higher than it should. Can someone please explain why doesn't "article"'s hitbox include the "header"? And how ti fix it? Thanks.
You're missing a either a overflow: hidden or a clear: left declaration. You should always clear floating objects or declare overflow to be hidden (carefully!).
article {
overflow: hidden;
}
Or:
div#wrapper div.related {
width: 100%;
height: 960px;
border-top: 1px solid #808080;
margin-top: 20px;
clear: left;
}
Why/how overflow: hidden works
When you set a block-level element to have overflow: hidden, you're actually telling the browser change how it handles block elements. Functionally, you told the browser to contain normal elements (including floated ones). Things that will exceed the total dimensions of the box, usually by relative/absolute positioning, or images with huge widths, will get clipped to the wrapper's width. Drop down regions that cross over a container with overflow: hidden may cause them to get clipped as they enter as well.
Elements at the end of a overflow: hidden container will also have padding-bottom and margin-bottom applied.
Another answer: https://stackoverflow.com/a/3416217/24950
You need to clear div#wrapper div.related. Try adding the following to your CSS:
div#wrapper div.related {
clear: both;
}

How can I force overflow: hidden to not use up my padding-right space

I have the following code:
<div style="width: 100px;
overflow: hidden;
border: 1px solid red;
background-color: #c0c0c0;
padding-right: 20px;
">
2222222222222222222222111111111111111111111111113333333333333333333</div>
(XHTML 1.0 transitional)
What happens is that the padding-right doesn't appear, it's occupied by the content, which means the overflow uses up the padding right space and only "cuts off" after the padding.
Is there any way to force the browser to overflow before the padding-right, which means my div will show with the padding right?
What I get is the first div in the following image, what i want is something like the 2nd div:
image
I have the same problem with the overflow:hidden; obeying all the padding rules, except for the right hand side. This solution works for browsers that support independent opacity.
I just changed my CSS from:
padding: 20px;
overflow: hidden;
to
padding: 20px 0 20px 20px;
border-right: solid 20px rgba(0, 0, 0, 0);
Having container divs works fine, but that effectively doubles the amount of divs on a page, which feels unnecessary.
Unfortunately, in your case this won't work so well, as you need a real border on the div.
Your best bet is to use a wrapping div and set the padding on that.
I had a similar problem that I solved by using clip instead of overflow. This allows you to specify the rectangular dimensions of the visible area of your div (W3C Recommendation). In this case, you should specify only the area within the padding to be visible.
This may not be a perfect solution for this exact case: as the div's border is outside the clipping area, that will become invisible too. I got around that by adding a wrapper div and setting the border on that, but since the inner div must be absolutely positioned for clip to apply, you would need to know and specify the height on the wrapper div.
<div style="border: 1px solid red;
height: 40px;">
<div style="position: absolute;
width: 100px;
background-color: #c0c0c0;
padding-right: 20px;
clip: rect(auto, 80px, auto, auto);">
2222222222222222222222111111111111111111111111113333333333333333333</div>
</div>
Wrap the div and apply padding to the parent
.c1 {
width: 200px;
border: 1px solid red;
background-color: #c0c0c0;
padding-right: 50px;
}
.c1 > .c1-inner {
overflow: hidden;
}
<div class="c1">
<div class="c1-inner">2222222222222222222222111111111111111111111111113333333333333333333
</div>
</div>
If you have a right-adjacent element to the one in question, put padding on its left. That way the content from the left element will flow up to but not past its margin, and the left padding on the right-adjacent element will create the desired separation. You can use this trick for a series of horizontal elements which may have content that needs to be cut off because it is too long.