Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Text Bottom Margin Ignored

Tags:

html

css

Ok, I hope this isn't a simple oversight but I have been working on this for hours!

I have a fairly complex HTML / CSS structure on a page I'm working with. I have text at the very bottom of the page that is in a div with a bottom margin of 10px;. That div is in another div with a bottom margin of 10px;.That div is in other divs on up the chain until <body>.

For some reason the text butts right up against the bottom of the div it is inside. I have created a minimalist repro for people to look at. It does reproduce the problem, I just hope I haven't removed any other issues that are contributory to the issue.

I did get it working in the latest chrome at one point with a height: 100%; somewhere in there (I don't remember where now) but it didn't fix the problem in firefox and ie. Both of those browsers had bizarre behavior with that css, they initially displayed with the correct bottom margin size but instantly jumped back down so that the text had no bottom margin again. It was like a little blip.

Oh, also in my repro html ie isn't displaying anything centered (at least ie9). I'm hoping that won't be a problem. I can certainly fix that issue easily enough myself.

In chrome, if you inspect element it highlights the text div in blue and the blue bounding box shows that the div extends beyond where it is currently being displayed.

Here is the minimalist example: http://www.del337ed.com/repro.html

I appreciate everyone's input / help.

like image 219
omatase Avatar asked Jan 18 '23 18:01

omatase


2 Answers

Add overflow: hidden to #SubmissionDetails to fix the margin problem by preventing the behaviour of collapsing margins on that div.

Add a doctype as the very first line to escape Quirks Mode and fix your page in Internet Explorer:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

(You could also use the much shorter <!DOCTYPE html>, I just stuck with what you had)

Making this change will also improve things in other browsers (that is, it will improve the consistency).

like image 171
thirtydot Avatar answered Jan 24 '23 16:01

thirtydot


In your example, the div which contains the markup for the thoughts - which currently has no class assiciated with it add the following:

height: auto; overflow: hidden;
like image 26
ScampDoodle Avatar answered Jan 24 '23 16:01

ScampDoodle