I'm trying to make a website with no vertical scrolling for a page, but i need that one of the DIVs i have to expand vertically to the bottom of the page (at most), and that when it has content that does not fit, the div should create a vertical scroller.
i already have the css for the inside of the div figured out in this fiddle, creating the scroller when needed. i also have figured out how to make the container div grow to occupy exactly the vertical space it has in the page. i just can't make them work out together!
please have in mind that in jsfiddle you won't be able to view the content of the whole website and in that sense what you get for the 2nd fiddle doesn't really show what's being done, but it works as i intended though.
just another note: as they are different fiddles, the id#container div in the 1st fiddle is he id#dcontent div of the 2nd example.
there is one other thing: for a type of content, this div will scroll vertically, but for other type of content, i want it to scroll horizontally, as it will have a product "slider" displaying elements horizontally inside this DIV.
please also look at this photo because it might be easier to understand what i'm trying to say: PICTURE
i tried looking to other questions regarding these topics, but none seemed to cover all of the aspects i'm trying to solve... :S
if there is something else i can provide to help you/me :) figuring it out, pls let me know!
thanks!
EDIT1: fixed typos
EDIT2: added picture for explanation
Try this:
CSS:
HTML:
If you don't like absolute positioning in this case, just can play with making a parent and child div to this one, both with
position:relative
.EDIT: Below should work (I just put the css inline for the moment):
i think it's pretty easy. just use this css
after this just give this class to ur div just like -
Quick Answer with Main Points
Pretty much the same answer as the best chosen answer from @Joum, to quicken your quest of trying to achieve the answer to the posted question and save time from deciphering whats going on in the syntax --
Answer
Set position attribute to fixed, set the top and bottom attributes to your liking for the element or div that you want to have an "auto" size of in comparison to its parent element and then set overflow to hidden.
Wallah! This is all you need for your special element that you want to have a dynamic height according to screen size and or dynamic incoming content while maintaining the opportunity to scroll.
This is what I managed to do so far. I guess this is kind of what you're trying to pull out. The only thing is that I can still not manage to assign the proper height to the container DIV.
JSFIDDLE
The HTML:
And the CSS:
This is a horizontal solution with the use of FlexBox and without the pesky
absolute
positioning.Well, after long research, i found a workaround that does what i need: http://jsfiddle.net/CqB3d/25/
CSS:
HTML:
might not work with the horizontal thingy yet, but, it's a work in progress!
I basically dropped the "inception" boxes-inside-boxes-inside-boxes model and used fixed positioning with dynamic height and overflow properties.
Hope this might help whoever finds the question later!
EDIT: This is the final answer.