ilikephp Posted April 22, 2008 Share Posted April 22, 2008 Hello all!! inside this, how can add please the measurement for the width also? <div style='height: 440px; overflow: auto;'> and one more question: Inside the DIV, how can I set margins? Coz I trying to use .css styles, but nothing happens! Thnaks a lott... Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/ Share on other sites More sharing options...
ilikephp Posted April 22, 2008 Author Share Posted April 22, 2008 Hello all!! Inside the DIV, how can I set margins? Coz I trying to use .css styles, but nothing happens! Thnaks a lott... Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-524122 Share on other sites More sharing options...
wildteen88 Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-524151 Share on other sites More sharing options...
ilikephp Posted April 23, 2008 Author Share Posted April 23, 2008 Thanks a lot for the explanation If I need to change the font size in a certain DIV, how can I put the code in a .css style and apply it? Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-524722 Share on other sites More sharing options...
wildteen88 Posted April 23, 2008 Share Posted April 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-525281 Share on other sites More sharing options...
ilikephp Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/102351-solved-set-margins/#findComment-525804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.