Margin top in inline element

This is not Firefox-only, and defined in the CSS 2.1 Specification: 8.3 Margin properties: ‘margin-top’, ‘margin-right’, ‘margin-bottom’, ‘margin-left’, and ‘margin’ Margin properties specify the width of the margin area of a box. The ‘margin’ shorthand property sets the margin for all four sides while the other margin properties only set their respective side. These properties … Read more

What does auto do in margin: 0 auto?

When you have specified a width on the object that you have applied margin: 0 auto to, the object will sit centrally within it’s parent container. Specifying auto as the second parameter basically tells the browser to automatically determine the left and right margins itself, which it does by setting them equally. It guarantees that … Read more

How to set margin of ImageView using code, not xml

android.view.ViewGroup.MarginLayoutParams has a method setMargins(left, top, right, bottom). Direct subclasses are: FrameLayout.LayoutParams, LinearLayout.LayoutParams and RelativeLayout.LayoutParams. Using e.g. LinearLayout: LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(left, top, right, bottom); imageView.setLayoutParams(lp); MarginLayoutParams This sets the margins in pixels. To scale it use context.getResources().getDisplayMetrics().density DisplayMetrics

How do I uncollapse a margin? [duplicate]

well you need something in between to “break” the collapsing. my first thought was to use a div with display:none set in between, but that doesn’t seem to work. so I tried: <div style=”overflow: hidden; height: 0px; width: 0px;”>.</div> which seems to do the job nicely (at least in firefox, don’t have internet explorer installed … Read more

Why can’t I center with margin: 0 auto?

You need to define the width of the element you are centering, not the parent element. #header ul { margin: 0 auto; width: 90%; } Edit: Ok, I’ve seen the testpage now, and here is how I think you want it: #header ul { list-style:none; margin:0 auto; width:90%; } /* Remove the float: left; property, … Read more