CSS différent selon OS

Fermé
jawaad35 Messages postés 90 Date d'inscription dimanche 4 juillet 2010 Statut Membre Dernière intervention 2 mai 2013 - 17 mars 2013 à 16:40
jawaad35 Messages postés 90 Date d'inscription dimanche 4 juillet 2010 Statut Membre Dernière intervention 2 mai 2013 - 17 mars 2013 à 17:09
Bonjour,

Je souhaiterais utiliser un CSS différent selon l'OS de l'ordinateur de l'internaute.

Actuellement j'ai çà sur ma page:

<!-- CSS -->
<link rel="stylesheet" href="{$Zx_Immo_theme}/css/reset.css" type="text/css" />
<link rel="stylesheet" href="{$Zx_Immo_theme}/style.css" type="text/css" />
<link rel="stylesheet" href="{$Zx_Immo_theme}/css/reponse.css" type="text/css" />
<link rel="stylesheet" href="{$Zx_Immo_theme}/css/superfish.css" type="text/css" />
<link href="{$Zx_Immo_theme}/css/formulaire.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/ico" href="favicon.ico" />


Et je crois qu'il faut mettre çà pour changer le CSS si besoin:

<script type=text/javascript>

var csstype="inline" //Specify type of CSS to use. "Inline" or "external"

var mac_css='body{font-size: 14pt; }' //if "inline", specify mac css here
var pc_css='body{font-size: 12pt; }' //if "inline", specify PC/default css here

var mac_externalcss='/style/macstyle.css' //if "external", specify Mac css file here
var pc_externalcss='/style/pcstyle.css'   //if "external", specify PC/default css file here

///////No need to edit beyond here////////////

var mactest=navigator.userAgent.indexOf("Mac")!=-1
if (csstype=="inline"){
document.write('<style type="text/css">')
if (mactest)
document.write(mac_css)
else
document.write(pc_css)
document.write('</style>')
}
else if (csstype=="external")
document.write('<link rel="stylesheet" type="text/css" href="'+ (mactest? mac_externalcss : pc_externalcss) +'">')

</script>


Je ne sais pas du tout comment mettre çà sur mon site. Quelqu'un pourrait m'aider.

Merci à vous

1 réponse

jawaad35 Messages postés 90 Date d'inscription dimanche 4 juillet 2010 Statut Membre Dernière intervention 2 mai 2013 10
17 mars 2013 à 17:09
J'ai essayé comme çà mais le site ne s'affiche même plus...

<!-- CSS -->
var csstype="inline" //Specify type of CSS to use. "Inline" or "external"

var mac_css='body{font-size: 14pt; }' //if "inline", specify mac css here
var pc_css='body{font-size: 12pt; }' //if "inline", specify PC/default css here

var mac_externalcss='{$Zx_Immo_theme}/style_mac.css' //if "external", specify Mac css file here
var pc_externalcss='{$Zx_Immo_theme}/style_win.css'   //if "external", specify PC/default css file here

///////No need to edit beyond here////////////

var mactest=navigator.userAgent.indexOf("Mac")!=-1
if (csstype=="inline"){
document.write('<style type="text/css">')
if (mactest)
document.write(mac_css)
else
document.write(pc_css)
document.write('</style>')
}
else if (csstype=="external")
document.write('<link rel="stylesheet" type="text/css" href="'+ (mactest? mac_externalcss : pc_externalcss) +'">')

<link rel="stylesheet" href="{$Zx_Immo_theme}/css/reset.css" type="text/css" />
<link rel="stylesheet" href="{$Zx_Immo_theme}/css/reponse.css" type="text/css" />
<link rel="stylesheet" href="{$Zx_Immo_theme}/css/superfish.css" type="text/css" />
<link href="{$Zx_Immo_theme}/css/formulaire.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/ico" href="favicon.ico" />
0