Archive

Posts Tagged ‘Border’

Internal div padding…

March 12th, 2009 ben No comments

So today I was playing around with -moz-border-radius and I was having problems with text touching the border of my div, ideally I wanted some sort of internal margin… ok so, padding I thought… 5px or so should do it.

I would have been right as well, except I had defined a width for the div and when used in combination with the padding property it was causing the div to expand beyond the width I had specified, ugh!

To get around this I had to take the border size into consideration:


border:                      4px #BB834B solid;
padding:                     10px;
width:                       180px;

would become:


border:                      4px #BB834B solid;
padding:                     10px;
width:                       170px;

8px have been deducted for the left (4px) and right (4px). This makes sense, but it would make more sense for the borders to be deducted from the width, not added. If anyone can suggest a better method, I would be very interested!

UPDATE:

As it happens, I have found a better solution, rather than deducting the borders from the width… simply don’t determine a width, but wrap the div around an outer div (which has its width set). That way the inner div will not expand when you add the padding:


<div class='outer_div' style='width: 200px'>
<div class='inner_div' style='border: solid 4px #000000; padding: 10px;'>
</div>

</div>

Categories: CSS2, CSS3, Web Standards, images Tags: , , , , ,

Exploring CSS3 border-radius on Safari 4 and Firefox 3

February 26th, 2009 ben No comments

Thanks to Safari 4.0 Beta I had the oppurtunity to play with ‘border-radius’ property which should soon be implemented in all major browsers as part of the CSS3 standard. Using only one line of code I can turn an ordinary div, into one with round edges.

border-radius:            1em;

This simple line of code can make a dramatic change to the appearance of a site and prevents designers needing to use complex (although elegant, NiftyCube) 3rd party solutions. At present Safari 4.0 beta and Firefox 3 use a slightly different syntax:

-moz-border-radius:       1em;

for firefox &

-webkit-border-radius:    1em;

for Safari. Obviously you don’t just have to use relative sizes (em), pixel sizes will work just as well. Roll on CSS3!

Categories: CSS3, Web Standards Tags: , , ,