HabboxWiki needs you!
Are you a Habbo buff? Or maybe a rare trader with a bunch of LTDs? Get involved with HabboxWiki to share your knowledge!
Join our team!
Whether you're raving for rares, excited for events or happy helping, there's something for you! Click here to apply
Need a helping hand?
Check out our guides for all things to help you make friends, make rooms, and make money!


Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Thumbs up [TUT][CSS] Fixing Padding + Margin On IE!

    On Internet Explorer, when you make a <div> the padding is different than FireFox and Safari. This tut will show you how to fix it

    If i used this code;

    HTML Code:
    <style type="text/css">
    .Box
    {width: 500px;
    margin: 20px;
    padding: 10px;
    background: url('BackgroundWithWidthOf500px.GIF');
    }
    </style>
     
    <div id="Box">
    Text Text Text!!
    </div>
    FireFox and safari would make a box that is 540px wide (space for text/500px + margin/20px + padding/10px left padding/10px right padding).

    But Internet Explorer would make a box 500px wide (space for text/460px + margin/20px + padding/10px left padding/10px right padding).

    This can be realy annoying when your using background images with your divs, or when the divs NEED to be an exact width. But the solution is simple

    HTML Code:
    <style type="text/css">
    .Box
    {width: 460px !important;
    width /**/:500px;
    margin: 20px;
    padding: 10px;
    background: url('BackgroundWithWidthOf500px.GIF');
    }
    </style>
     
    <div id="Box">
    Text Text Text!!
    </div>
    The code above (called the box model hack) has 2 widths in, the 1st one is understood by IE, Safari and FireFox. But the 2nd one, because of the comment, confuses FireFox and Safari and is only read by Internet Explorer. And that fixes the problem.

    For the 1st width, put the width minus the padding and margin of the box, and for the 2nd width, put the actual width you want the box to be.

    Enjoy


    Thread closed by Yoshimitsui (Forum Super Moderator): Due to being bumped.
    Last edited by Yoshimitsui; 21-03-2009 at 01:10 PM.
    Lets set the stage on fire, and hollywood will be jealous.

  2. #2
    Join Date
    Mar 2008
    Posts
    779
    Tokens
    0

    Default

    Pritty good, it's also valid which is unusual for a CSS hack.

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,131

    Latest Awards:

    Default

    I just use .width as an IE only attribute. I think it's valid, though I'm not sure..

  4. #4
    Join Date
    Mar 2008
    Posts
    779
    Tokens
    0

    Default

    Quote Originally Posted by Invent View Post
    I just use .width as an IE only attribute. I think it's valid, though I'm not sure..
    The .attribute hack is invalid in CSS.

  5. #5
    Join Date
    Sep 2008
    Posts
    718
    Tokens
    0

    Default

    lol... ik i'm bumping an old thread but I think Iszak told me you can just fix this by declaring a DOCTYPE?
    +.net - omg it's coming o_o

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •