Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Browser Detection, load different css file
New Posts  All Forums:Forum Nav:

Browser Detection, load different css file

post #1 of 3
Thread Starter 
So im trying to load up two different style sheets. It seems Firefox and IE dont want to cooperate on the same stylesheet. So now I have to create two of them and load them depending on the browser.
However, I cant seem to get it working.

Here is my code
Code:

<!--[if IE 6]>

<link rel="stylesheet" type="text/css" href="styleie.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="styleie.css" />
<![endif]-->
<[if !IE]>
<link rel="stylesheet" type="text/css" href="style.css" />
<[endif]>
What I want it to do is:
Quote:
IF
Browser = IE
LOAD styleie.css
IF
Browser = FF
LOAD style.css
I think i've done it right but it doesnt work
    
CPUMotherboardGraphicsRAM
Intel i7-4850HQ  Yes GT 750M 16GB Corsair 
Hard DriveHard DriveOSMonitor
512GB SSD 1TB Buffalo Drivestation OSX Mavericks 15" 2880 x 1800 IPS 
MouseOther
Magic Mouse Mobee Magic Charger 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel i7-4850HQ  Yes GT 750M 16GB Corsair 
Hard DriveHard DriveOSMonitor
512GB SSD 1TB Buffalo Drivestation OSX Mavericks 15" 2880 x 1800 IPS 
MouseOther
Magic Mouse Mobee Magic Charger 
  hide details  
Reply
post #2 of 3
You're trying to do conditional comments. Those don't work in Firefox, or anything other than IE. Remove the <! [if !IE] > and <[endif] --> tags, and that stylesheet will work.

Order your stylesheets like so...

Firefox (main.css)
IE 7 (ie.css)
IE 6 (ie6.css)

This way, IE 6 gets the most fixes, IE 7 gets some, and Firefox gets none. Also develop in this order. It will work the best.
AMD Power
(16 items)
 
Macbook Pro
(13 items)
 
Web Server
(13 items)
 
CPUMotherboardGraphicsRAM
AMD FX 9590 Asrock 990FX Extreme9 ASUS Radeon HD 7870 2GB 8GB (2x4GB) G.SKILL 1866 
Hard DriveOptical DriveCoolingOS
Hitachi 1TB Blu-Ray reader / DVD burner Coolermaster Water Cooling kit bundled with 9590 Windows 10 x64 
MonitorMonitorMonitorKeyboard
Dell 2209WA Dell 2209WA Dell 2209WA Logitech G910 Orion Spark 
PowerCaseMouseMouse Pad
SeaSonic S12G 650W Corsair Vengeance C70 Gunmetal Black Razer DeathAdder 2013 Ripper XXL 
CPUMotherboardGraphicsRAM
Intel i7  Apple Intel HD 3000 / AMD Radeon HD 6750M 16GB (2x4GB) GEIL DDR3-1333 
Hard DriveOptical DriveOSMonitor
SAMSUNG 840 EVO Apple Combo Drive OS X 10.9 Mavericks 15" 1680x1050 
PowerCase
Apple power brick Aluminum 
CPUMotherboardGraphicsRAM
Phenom II 940 BE @3.2GHz DFI LanParty 7200GS 8GB DDR2 GSkill 1000 
Hard DriveOSMonitorPower
30 GB SSD (webroot), 80GB (OS) Gentoo amd64 SSH 430 Watt Rosewill 
  hide details  
Reply
AMD Power
(16 items)
 
Macbook Pro
(13 items)
 
Web Server
(13 items)
 
CPUMotherboardGraphicsRAM
AMD FX 9590 Asrock 990FX Extreme9 ASUS Radeon HD 7870 2GB 8GB (2x4GB) G.SKILL 1866 
Hard DriveOptical DriveCoolingOS
Hitachi 1TB Blu-Ray reader / DVD burner Coolermaster Water Cooling kit bundled with 9590 Windows 10 x64 
MonitorMonitorMonitorKeyboard
Dell 2209WA Dell 2209WA Dell 2209WA Logitech G910 Orion Spark 
PowerCaseMouseMouse Pad
SeaSonic S12G 650W Corsair Vengeance C70 Gunmetal Black Razer DeathAdder 2013 Ripper XXL 
CPUMotherboardGraphicsRAM
Intel i7  Apple Intel HD 3000 / AMD Radeon HD 6750M 16GB (2x4GB) GEIL DDR3-1333 
Hard DriveOptical DriveOSMonitor
SAMSUNG 840 EVO Apple Combo Drive OS X 10.9 Mavericks 15" 1680x1050 
PowerCase
Apple power brick Aluminum 
CPUMotherboardGraphicsRAM
Phenom II 940 BE @3.2GHz DFI LanParty 7200GS 8GB DDR2 GSkill 1000 
Hard DriveOSMonitorPower
30 GB SSD (webroot), 80GB (OS) Gentoo amd64 SSH 430 Watt Rosewill 
  hide details  
Reply
post #3 of 3
Thread Starter 
Ah, so the order of them actually matters

Thanks, sorted now
+rep
    
CPUMotherboardGraphicsRAM
Intel i7-4850HQ  Yes GT 750M 16GB Corsair 
Hard DriveHard DriveOSMonitor
512GB SSD 1TB Buffalo Drivestation OSX Mavericks 15" 2880 x 1800 IPS 
MouseOther
Magic Mouse Mobee Magic Charger 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel i7-4850HQ  Yes GT 750M 16GB Corsair 
Hard DriveHard DriveOSMonitor
512GB SSD 1TB Buffalo Drivestation OSX Mavericks 15" 2880 x 1800 IPS 
MouseOther
Magic Mouse Mobee Magic Charger 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Browser Detection, load different css file