问题描述:

I have a DIV with two absolute DIVs inside, one on top and one on the bottom which together form a nice UI window.

Also inside the DIV is the actual content window which determines the height of the parent DIV. Here is a fiddle.

I'm trying to have it so the content is NOT confined to the inner content window, but so that it will instead fill the parent DIV. As if the absolute DIVs for the UI and the inner content DIV are one DIV. This will:

  • overlap the top of the content with the top UI DIV
  • overlap the bottom of the content with the bottom UI DIV
  • emulate an even margin between the inner content window and the parent DIV

I was able to hard-code this with specific CSS (uncomment the commented out portion of the fiddle).

But what I couldn't do is figure out why margin-bottom: -20px does not apply -20px to the bottom of the margin and make the parent DIV 20 pixels shorter. I swear that has worked before. Not today.

网友答案:

This may be stupid, but have you tried floating the inner DIV, that, from what I can think of, should take it outside of the normal flow of text, but still retain the text properties both the parent and inner DIV apply to it?

相关阅读:
Top