Results 1 to 5 of 5

Thread: if else in css

  1. #1
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question if else in css

    Hi..
    I want to apply setting depending on browser version...
    I'll show u a prototype

    .mycssclass{

    [if IE 6]
    COLOR:RED;
    [ELSE IF IE 7]
    COLOR:blue;
    [ELSE]
    COLOR:GREEN;
    [END IF]
    }

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    For IEs, you can use conditional comments:
    Code:
    <style type="text/css">
      .mycssclass {
        color: green;
      }
    </style>
    <!--[if IE 6]>
    <style type="text/css">
      .mycssclass {
        color: red;
      }
    </style>
    <![endif]-->
    <!--[if IE 7]>
    <style type="text/css">
      .mycssclass {
        color: blue;
      }
    </style>
    <![endif]-->
    These are mostly applied to work around IE's many bugs. If you want to do other browsers too, firstly be very sure of what you're doing (if you're getting differing behaviour, it's probably because you haven't followed the standards properly) and then use JS, remembering to provide a non-JS fallback for non-JS users.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am pretty sure you cant use that format in css but try to create clean, standard compliant css files and it should work in IE and FF too.
    If you need help try posting the problems here

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    try to create clean, standard compliant css files and it should work in IE and FF too.
    Considering that IE7 doesn't support half of CSS2, let alone the bits of CSS3 that other browsers are now starting to integrate, I doubt that very much.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default thank you..

    thank you.. for all ur support

Tags for this Thread

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
  •