SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional Comments

    Is there a way to use conditional comments inside a style sheet?

    I have a style sheet that looks like this:
    Code:
    @charset "utf-8";
    #container {
    	background-image: url(../images/background.png);
    	height: 768px;
    	width: 1024px;
    	margin-right: auto;
    	margin-left: auto;
    	background-repeat: no-repeat;
    }
    #container #sidebar {
    	width: 200px;
    	float: left;
    	padding-top: 280px;
    	padding-left: 150px;
    }
    #container #maincontent {
    	height: 400px;
    	width: 400px;
    	border: medium groove #330033;
    	float: right;
    	margin-top: 220px;
    	margin-right: 200px;
    }
    But because margins are different in IE than in firefox I'd like to put in some comments into this style sheet depending upon IE or not. I can do it in the header using tags like <!-- if[IE]--> but I'd rather do it in the stylesheet if possible.

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use the star selector hack for IE 6 and IE 5.5:
    Code:
    * html #container { }

  3. #3
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks. That works great. I don't have access to IE7 but I imagine it doesn't work for IE7. Do the margins look closer to firefox in IE7?

  4. #4
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They seem to look the same, but why do you use padding on your sidebar and margin on the maincontent?


Bookmarks

Posting Permissions

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