html - P tag inside div: Setting margin-top to p tag pushes parent div down too -


I understand why the margin is top of the setting: 100px on the P tag brings its basic element down with it its Can not be determined Anyone got any ideas?

HTML:

  & lt; div id = "sections" & gt; & Lt; Section id = "biography" & gt; & Lt; Div class = "inner left featured" & gt; & Lt; P class = "sectionTitle" & gt; Bio & lt; Br / & gt; & Lt; Small & gt; About me & lt; / Small> & Lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "infarriage" & gt; & Lt; / Div & gt; & Lt; / Section & gt; & Lt; Section id = "blah" & gt; & Lt; Div class = "inner left featured" & gt; & Lt; p class = "sectionTitle" & gt; Blah & lt; Br / & gt; & Lt; Small & gt; Blah blah & lt; / Small> & Lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "innerwrite" & gt; & Lt; / Div & gt; & Lt; / Section & gt; & Lt; / Div & gt;   

CSS:

  # partition {width: 100%; Height: auto; Margin: -30 px auto; } # Section section {width: 200px; Height: 468 pixels; Swim left; Margin-right: 15px; Opacity: 0.9; } #ignation #bigography Inner Lifespan {Background-Image: URL ('/ Shared / Assets / Images / Biotele Pages'); Background repeat: no duplication; Text align: center; Width: 100%; Height: 100%; Background color: blue; } #ignation #bog Inner LifeSite P {font-weight: bold; } #ignation #biosography Inner Lightsite P minor (font-weight: normal; font-size: 0.65em; } #ignation #blow Inner Lifestyle {Background-Image: URL ('/ Shared / Assets / Images / Blahtile Page'); Background repeat: no duplication; Width: 100%; Height: 100%; Text align: center; Background color: green; } #ignation #blow Inner Lifestyle Page {font-weight: bold; Margin-top: 100px; } #ignation #blow Inner Lift C minor P (font-weight: normal; font-size: 0.65em; }    

due to falling margin of this CSS box Model definition:

In CSS, the margins of a single margin around two or more boxes (which may or may not be a sibling) You can combine to create. The margins that add in this way fall, and the resulting joint fringe is called collapsed margin.

By definition:

Inline- Block boxes (not even with their in-flow children) do not collapse.

Therefore change inline-block to p to avoid this behavior.

Demo :

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -