Centering div

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Can I center div-tag somehow if I want to define div width in pixels?

If I define left, right and width in percents it works, but then I can't
define minimum width? (what "min-width" does anyway?)

Re: Centering div

"H. Mki" wrote:

Quoted text here. Click to load it /

Quoted text here. Click to load it

Min-width, which is not supported by IE, defines a minimum width and takes
priority over the width property. For example:

  width: 20em;
  min-width: 150px;

Would create an element 20em wide, unless the font was small enough that
20em was less than 150px, in which case it would be 150px instead.

David Dorward       < <
                     Home is where the ~/.bashrc is

Re: Centering div

H=2E M=E4ki wrote:
Quoted text here. Click to load it

This likely can be done if you do not mind using javascript, but be
aware that a small number of browsers have script turned off. I will
outline what is involved below. In case you are interested, I likely
can find one of my pages that uses it.

Script can be written to detect the screen width.Then the division is
written using a document.write which uses absolute positioning for the
division and the detected  screen width. The needed absolute left
position for the division is calculated using script by division of the
detected screen width by 2 to detect the screen width center, and then
by subtraction of 1/2 of the desired division width.

Site Timeline