Jump to content


If statements?


5 replies to this topic

#1 liquid486

    Young Padawan

  • Members
  • Pip
  • 67 posts

Posted 27 July 2005 - 09:50 PM

Coming from a coding background, I was wondering if there was any way to do something like this:
if (browser=IE) {
stylesheet=IE.css
}
else {
stylesheet=style.css
}

Any ideas?

#2 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 27 July 2005 - 10:22 PM

using php, it would be almost exactly like that. but more like

$browser = $_SERVER['HTTP_USER_AGENT']

if($browser="MSIE"){
echo "IEstylesheet.css";
} else{
echo "stylesheet.css";
}


actually, come to think.. theres a way with just using clientside scripts.. let me look around...

<link rel="stylesheet" type="text/css" media="screen" href="/styles/screen.css" />
<!--[if lte IE 5.5]>
<link rel="stylesheet" type="text/css" media="screen" href="/styles/ie5.css" />
<![endif]-->
i never used that right above, but it uses conditional elements

#3 raenef

    Code Enforcer

  • Members
  • PipPipPip
  • 540 posts
  • Location:Battle Creek, Michigan
  • Interests:Web Development and Graphic Design

Posted 27 July 2005 - 10:26 PM

Something like this: http://www.thesitewi...xcludecss.shtml perhaps?

#4 softLearner

    Young Padawan

  • Members
  • Pip
  • 128 posts

Posted 28 July 2005 - 04:01 AM

Check this out site out here. Yo ucan create a whole stylesheet in PHP and include just like a style sheet. This way you can have one style sheet, but it'll only output for the browser you're using.

It explais it better on the site. Its pretty cool.

#5 liquid486

    Young Padawan

  • Members
  • Pip
  • 67 posts

Posted 28 July 2005 - 03:25 PM

Thanks for the help, thats exactly what I was looking for. Why do people still use the box model hack and other css tricks when this seems to be much simpler...?

#6 softLearner

    Young Padawan

  • Members
  • Pip
  • 128 posts

Posted 29 July 2005 - 05:08 AM

SOme people may not be using PHP for their sites, or can't be bothered to code their styles in PHP etc.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users