Quantcast
Channel: Why does this CSS margin-top style not work? - Stack Overflow
Browsing all 15 articles
Browse latest View live

Answer by Mithilesh Tipkari for Why does this CSS margin-top style not work?

Just for a quick fix, try wrapping your child elements into a div element like this - <div id="outer"> <div class="divadjust" style="padding-top: 1px"> <div id="inner"> Hello world!...

View Article



Answer by Qiang for Why does this CSS margin-top style not work?

What @BoltClock mentioned are pretty solid. And Here I just want to add several more solutions for this problem. check this w3c_collapsing margin. The green parts are the potential thought how this...

View Article

Answer by atgr24869 for Why does this CSS margin-top style not work?

Have you tried !important before all, it will force everything: margin:50px 50px 50px 50px !important;

View Article

Answer by Ata Iravani for Why does this CSS margin-top style not work?

Use padding-top:50pxfor outer div. Something like this: #outer { width:500px; height:200px; background:#FFCCCC; margin:50px auto 0 auto; display:table;} Note: padding will increase the size of your...

View Article

Answer by viditkothari for Why does this CSS margin-top style not work?

I guess setting the position property of the #inner div to relative may also help achieve the effect. But anyways I tried the original code pasted in the Question on IE9 and latest Google Chrome and...

View Article


Answer by Mustafa M Jalal for Why does this CSS margin-top style not work?

try this: #outer { width:500px; height:200px; background:#FFCCCC; margin:50px auto 0 auto; display:table; } #inner { background:#FFCC33; margin:50px 50px 50px 50px; padding:10px; display:block; }​...

View Article

Answer by Dave for Why does this CSS margin-top style not work?

Doesn't answer the "why" (has to be something w/ collapsing margin), but seems like the easiest/most logical way to do what you're trying to do would be to just add padding-top to the outer div:...

View Article

Answer by bookcasey for Why does this CSS margin-top style not work?

If you add any padding to #outer, it works. Demo #outer { width:500px; height:200px; background:#FFCCCC; margin:50px auto 0 auto; display:block; padding-top:1px; }

View Article


Answer by Brandon for Why does this CSS margin-top style not work?

Not sure why what you have doesn't work, but you can add overflow: auto; to the outer div.

View Article


Answer by BoltClock for Why does this CSS margin-top style not work?

You're actually seeing the top margin of the #inner element collapse into the top edge of the #outer element, leaving only the #outer margin intact (albeit not shown in your images). The top edges of...

View Article

Answer by harriyott for Why does this CSS margin-top style not work?

Not exactly sure why, but changing the inner CSS to display:inline-block; seems to work;

View Article

Answer by enderskill for Why does this CSS margin-top style not work?

Try using display: inline-block; on the inner div. #outer { width:500px; height:200px; background:#FFCCCC; margin:50px auto 0 auto; display:block; } #inner { background:#FFCC33; margin:50px 50px 50px...

View Article

Image may be NSFW.
Clik here to view.

Why does this CSS margin-top style not work?

I try to add margin values on a div inside another div. All works fine except the top value, it seems to be ignored. But why? What I expected: What I get: Code: #outer { width: 500px; height: 200px;...

View Article


Answer by Artemee Senin for Why does this CSS margin-top style not work?

Create new block formatting contextYou can use display: flow-root on the parent element to prevent margin collapsing through the containing element as it creates new Block Formatting Context.Changing...

View Article

Answer by Jackie Santana for Why does this CSS margin-top style not work?

If you have a margin collapse issue, then to resolve this you can adddisplay: flow-root; to the parent container.Aside from that, if margin-top is being ignored, try margin-top with a negative value,...

View Article

Browsing all 15 articles
Browse latest View live




Latest Images