Laran Evans
I develop software people love to use.
  • Home
  • About
  • Contact
  • Resume
  • Testimonials
Skip to content
  • Entrepreneurship
    • Leadership
    • Project Management
    • Team Development
    • Time Management
  • Motorcycles
    • Restoration Projects
  • Puzzles
  • Software Architecture
    • Cloud Computing
  • Software Development
    • Algorithms
    • CSS
    • Java
    • Javascript
    • MySQL
    • PHP
    • Python
    • Ruby and Rails
    • System Administration
Why Frameworks Die »

Box Model Hackery The Easy Way

By laran | Published: 2007/08/17

I’ve wrestled with the box model variations between IE and Mozilla for years. And today I finally arrived at what seems to be the absolute easiest way to make things work.

#mydiv { width: 500px; padding: 10px; margin: 0; border: 0; }
* html #mydiv { width: 480px; }

The first line is valid and interpreted by both browsers. The second line is interpreted only by IE. Setting the width to the width you want (500px) minus (padding + margin + border) will give you the effect you want. You’ll have the same size box in both browsers. Yeehah!

This entry was posted in CSS. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
Why Frameworks Die »

Post a Comment

Click here to cancel reply.

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • About Me

    I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods. Read more »

  • Subscribe

  • Similar Posts

    This Post is Unique

  • From Around the Web

      Shared Items
    • Recent Posts

      • The carbs are clean!
      • 80 pages of Ruby on Rails Performance Optimization Tips
      • Ruby Garbage Collection In-Depth
      • Binary Logic Basics
      • Kuali in Nacubo Magazine
    • Older Posts By Month

      Let's Talk

      Ask a question below. You'll be prompted for your name and email after you click the "Ask" button.

    Know more. Accomplish more. Succeed.