Previous Message
Next Message

Padding and divs, basic question

Sent by Christian Heilmann on 21 September 2005 00:12


> If I have a div that is set to 120px wide, and I want to drop some text into
> it, and have that text a few pixels in from the border of the div, is there
> some way to do it without messing with the 120px side of things:
> So that's just fine, but the "Something" is butted right up on the red
> border, I want it in somewhat, but then it changes the width if I use margin
> or padding, and I am betting various browsers deal with this in different
> ways.

Real browsers add the padding to the width, so if you want an element
with a width of 120px and padding you need to substract them:

#foo{
  width:100px;
  padding:0 10px;
}

Older versions of MSIE make a pig's ear out of that, and you'll need
to hack for them:
http://tantek.com/CSS/Examples/boxmodelhack.html


-- 
Chris Heilmann 
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/  
Binaries: http://www.onlinetools.org/
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: