Div not expanding even with content inside

后端 未结 8 2154
故里飘歌
故里飘歌 2020-12-24 00:23

I have a stack of divs inside of each other, all of which have an ID which specifies CSS only.

But for some reason the surrounding DIV tag only expands to it\'s anoi

相关标签:
8条回答
  • 2020-12-24 00:59

    There are two solutions to fix this:

    1. Use clear:both after the last floated tag. This works good.
    2. If you have fixed height for your div or clipping of content is fine, go with: overflow: hidden
    0 讨论(0)
  • 2020-12-24 01:01

    Floated elements don’t take up any vertical space in their containing element.

    All of your elements inside #albumhold are floated, apart from #albumhead, which doesn’t look like it’d take up much space.

    However, if you add overflow: hidden; to #albumhold (or some other CSS to clear floats inside it), it will expand its height to encompass its floated children.

    0 讨论(0)
  • 2020-12-24 01:05

    You have a fixed height on .infohold, so the .albumhold div will only add up to the height of .infohold (20px) + .albumpic (110px) plus any padding or margin which I haven't included there.

    Try removing the fixed height on .infohold and see what happens.

    0 讨论(0)
  • 2020-12-24 01:11

    Putting a <br clear="all" /> after the last floated div worked the best for me. Thanks to Brent Fiare & Paul Waite for the info that floated divs will not expand the height of the parent div! This has been driving me nuts! ;-}

    0 讨论(0)
  • 2020-12-24 01:13

    You probably need a clear fix.

    Try this:

    What methods of ‘clearfix’ can I use?

    0 讨论(0)
  • 2020-12-24 01:16

    You didn't typed the closingtag from the div with id="infohold.

    0 讨论(0)
提交回复
热议问题