Jump to content

[SOLVED] set margins...


ilikephp

Recommended Posts

When setting the width or height of any HTML element on the page you need to have a good understanding of the box model.

 

Browsers calculates the width of any HTML element by the following simple formula (l+r stands for left and right):

(borders l+r, padding l+r) + width = width;

 

So if you set up div as follows:

<div style="width: 100px;"> 100px wide DIV</div>

It'll be 100px wide, very simple.

 

Now if you apply 10px padding:

<div style="width: 100px; padding:10px"> 124px wide DIV</div>

The Div will now be 120px wide.

 

The DIV wll increase in size even more if you add a border:

<div style="width: 100px; padding:10px; border:2px solid #FF0000"> 120px wide DIV</div>

it'll now be 124px wide.

 

To keep the div at 100px wide you'll need to set the width 24px less than what it should be, so 76px.

 

The same principle applies to the height also, except this time you consider the top and bottom padding and borders

 

Margins don't have an affect on the size of an element.

Link to comment
https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-524151
Share on other sites

use the font-size property, eg:

 

div {
   font-size: 12px;
}

The above CSS will set any text with a DIV to 12px. If you to set the size to a specific DIV, give it a class eg:

 

<div>Normal sized text</div>

<div class="biggerText">Much Larger text</div>"

Set the following CSS:

.biggerText {
   font-size: 24px;
}

 

You can learn the basic of CSS over W3Schools.com. They also support code demo's which you can test live.

Link to comment
https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-525281
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.