Jump to content

using margin:0 auto, but still need margin


niche

Recommended Posts

What do I need to add/change to this style to center it AND have display a margin?

<div style="display:block;margin:0 auto;width:90px;">  <input  type="submit" value="Add to Cart" />  </div>

Link to comment
Share on other sites

You want margins on top/bottom or on left/right? If top and bottom just change the 0 (ie, margin: 4px auto;)If you want them on the sides, try applying left and right margins to the input itself. You might also need to put text-align: center on the div. Are you trying to create a liquid layout where the elements will not get any closer to each other if the browser window gets too small?

Link to comment
Share on other sites

Tried margin: 5 auto; instead of margin: 5px auto;. The correct format makes all the difference. I'm also very thankful for help looking at the same problem in different ways.Thanks to jwburnside and ShadowMage for their top-notch help.Niche

Link to comment
Share on other sites

Tried margin: 5 auto; instead of margin: 5px auto;. The correct format makes all the difference.
It's a good idea to always include a unit when defining widths and such. That's why I usually write margin: 0px auto; instead of just margin: 0 auto; like I see most people here do.
Link to comment
Share on other sites

Point. That's just another reminder of justsomeguys quote, "[know] why it works". I know now that the unit's need for it to work.Thanks Again, Niche

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...