SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    USA
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just purchased the book today. I will try and work with it tonight. I know what you mean about the outdated issue. Happens all the time. I also bought the Zen of CSS design. I like it because it has the graphic layouts of the designs that others did and describes them. So I guess that I am well on my way.

    I'll let you know how it goes.

  2. #27
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    USA
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been using the book and it has been very helpful. I would recommend it to be purchased. Very easy to understand.

    My layout works well in IE, Netscape, and FireFox. The only one that still has some quirks is Opera. I have researched a little and found that it is possible to use either PHP or Javascript to switch from one stylesheet to another based on the browser. How common is this? Do you feel that it is worth looking into further?

    I tried using the PHP code below but it didn't work. Has someone used this method before? Are there enough people using Opera that it would be worth diving farther into this?

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?php header( 'Content-Type: text/css');
    $browToFileMap = array (
    'IE' => '/css/layout_ie.css',
    'Opera' => '/css/layout_opera.css', );
    $defaultFile = '/css/layout_ie.css';
    $foundMatch = FALSE;
    $browser = get_browser();
    foreach( $browserToFile as $name => $file ) {
    if ( preg_match('/'.$name.'/i', $browser['browser']) ) {
    $foundMatch = TRUE;
    $fp = fopen( $file, 'r' );
    $fpassthru( $fp );
    }
    }
    if (!$foundMatch ) {
    $fp = fopen( $file, 'r' );
    $fpassthru( $fp );
    }
    ?>
    </body>
    </html>

    HTML file:
    <link rel="stylesheet" href="loader.php" type="text/css">

  3. #28
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That sort of browser sniffing is a dangerous practice. Just look at all those sites from 1998 (where browser sniffing was more or less required). You try looking at them in Mozilla or Opera 8, and get told to "upgrade" to Internet Explorer 4...

    It's usually sufficient to have one CSS file that caters for all standards-compliant browsers. You may need some hacks for IE/Win and IE/Mac, though, but those are fairly "safe" (at least the star-html hack).

    If it the number of hacks becomes large enough, it may be warranted to export them into one or two separate style sheets, which are served only to IE. For IE/Win, you can use conditional comments:
    HTML Code:
    <!--[if IE]>
      <link rel="stylesheet" type="text/css" href="iewin.css" media="screen">
    <![endif]-->
    For IE/Mac, you can use an escaped comment hack:
    Code:
    /*\*//*/
    @import url(iemac.css);
    /**/
    Birnam wood is come to Dunsinane

  4. #29
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    USA
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the answer Autistic Cuckoo. I will try this instead of the php. I think that it will be sufficient for what I need to do. It may not even be necessary.


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
  •