What is CSS ?

Resources and Magazine

Centering block element ?

There are multiple techniques for centering a block ; and the choice for the technique depends on whether you have the size set in percentages or in more absolute values.

Centering an entire page’s contents

body {

  text-align: center;

  min-width: 500px;

}

#wrapper {

  text-align: left;

  width: 500px;

  margin-left: auto;

  margin-right: auto;

}

Commented example

body {

  /* MSIE 5 doesn't center based on auto left/right margins,

     but 'text-align:center' does center top-level divs: */

  text-align: center;

  /* Specify a min-width for the body as wide as the 'wrapper'

      itself. This prevents negative (i.e. inaccessible)

     left-margins in narrow browser windows when using

     Navigator 6+/Mozilla on Win32: */

  min-width: 500px;

}

#wrapper {

  /* Reset alignment to compensate for ‘text-align:center’: */

  text-align: left;

  /* Specify the width of the . This should be the same

     as ‘body min-width’: */

  width: 500px;

  /* Set left and right margins to auto, thus centering the

      in the containing (body) tag: */

  margin-left: auto;

  margin-right: auto;

}

See also
http://www.bluerobot.com/web/css/center1.html

For more about the centering block , check out
http://css-discuss.incutio.com/?page=CenteringBlockElement

Tags: , ,
Your Ad Here

IE Double Margin Float Bug

 

It’s an Internet Explorer-exclusive bug wherein an that is floated – and given a margin in the same direction as the float – ends up with twice the specified margin size. The fix is extremely simple. All you have to do is apply a display: inline rule to your floated . So you simply go from something like this:

#content {
float: left;
width: 500px;
padding: 10px 15px; 
margin-left: 20px;
}

To something like this:

#content {
float: left; 
width: 500px; 
padding: 10px 15px; 
margin-left: 20px; 
display: inline;
}

For more about the double margin bug, check out http://www.cssnewbie.com/double-margin-float-bug

Tags:
Your Ad Here