Overflow: auto always show scroll - css

I have a parent div, I set max heigth, overflow auto for it. And it have two children div. But I saw the height of parent div equals sum of two children's height.
And It only working when I add padding bottom to Parent div or Last children div.
Thanks for any help.

If the children have in sum bigger height, you should increase the size of the parent.
I recommend you to learn about flex-box, here's a good website for that flex-box

Related

How can div be wider than parent td?

I have a div that is wider than its parent td.
How can it be that? The parent has no overflow set so it should really adapt to its content, right?
CSS of parent td:
CSS of child div:
Parent TD is 722px wide:
Child DIV is 960px wide:
You have a table with a set width of 720px. So the unique Table cell present in it, will have a 720px width too.
Using divs inside table rows can result width difference between child and parent.. I am not sure for your case but giving your child div an inherited width can solve it.
#contentslider1{width:inherit}

how to make a child div not to exceed its parent width if child's width is dynamic

In my jsp, I have a div whose width is determined by a javabean value. Basically it is being used to fill a bar. Some times the values are greater than 100, so the width becomes 300% (for example), thus going out of the parent's boundary.
I need to know, how I can limit the child div's width so that it doesn't exceed the parent boundary.
Thank you.
I just used a combination of the previous responses and it worked for me.
In my case I din't want to hardcode any pixel values but leave my child element fluid to grow and shrink to its parent element width.
Used for parent overflow: hidden; and for the child width: 100% !important;
Also noticed that the child doesn't have to be the direct child of the parent for this to work. For the record, my parent element is a Flex Container with flex-basis: 66%; which translates to a relative width in the Flexbox concept.
Apply the following CSS to the parent div:
overflow: hidden;
Or you might want to try the CSS max-width property on the child-div.
You can use width:100% !important on child div.This means it will fill only the parent div space only.
Alternatively you can also go for max-width and min-width concept.

extend the background of a div to fill the parent div's height

I have tried a dozen different solutions and nothing seems to work.
http://betelec.ergonomiq.net/societe/offres-d-emploi
On the page above, I want the teal background of the left sidenav to extend to the height of the white container around it.
The white container gets its height defined by the height of the largest child div (in this case, the mainbody).
I have tried setting the sidenav's div height to auto, but the div remains fixed height. If I set the div to a very large number like 10000px and have overflow hidden, nothing gets hidden.
I am completely at a loss.
Set parent element to position: relative; and then the child element to position: absolute; height: 100%;
Live example.
http://jsfiddle.net/pQdAr/
It looks like your left sidebar is positioned by float:left.
The following post may help you. How to match height of floating sibling divs

auto increasing height issue for nested divs

I want to increase the size of the outter div when the height of the inner div increases.
height:auto seems to be working only when the contents are added its expanding.. it doesnt seems to be expanding when the inside div height is more.Is there any solution for this in css?
Try to put overflow: hidden in the parent div or otherwise float it. Surely you have your inner div floated and then parent div doesn't consider it to expand its height. If this is the case, both solutions should work.

overflow:auto on child of overflow:hidden div?

I have a div that must be set to overflow:hidden, and I want one of its child divs to scroll through content; however, no matter how I play with the overflow on the child, it won't scroll. How can I override the inheritance?
You likely have not specified a height on the inner div.
Without height on the div its height will be the height of its content and hence it will never need to scroll. Of course with it being contained in an outer div that does have height and overflow:hidden its content disappears under the border of the outer div.

Resources