2010-09-06 3 views
0

Ce code fonctionne bien dans Firefox, mais pas dans IE, s'il vous plaît donner une solution en utilisant CSS (Pas de jquery ou javascript), le problème commence vous cliquez sur la portée à l'intérieur de la DIV!Lorsque vous cliquez sur le bouton div des outils (: actif) fonctionne bien dans Firefox mais pas dans IE

<style type="text/css"> 

.tools { 
    cursor:pointer; 
} 

.tools { 
    background-color:#aaa; 
    padding:5px; 
} 

.tools span { 
    background-color:green; 
    color:white; 
} 

.tools:hover { 
    background-color:#ccc; 
} 

.tools:hover span { 
    background-color:red; 

} 

.tools:active { 
    background-color:#333; 
    color:#fff; 
} 

.tools:active span { 
    background-color:blue; 
} 


</style> 

</head> 

<body onselectstart="return false;" > 
<div class="tools" style="width:100px; height:20px;"> 
<span> 
Hello world... 
</span> 
</div> 
</body> 

Répondre

3

Vous ne devez pas faire de div ou tout autre élément html comme un autre élément. Il n'y a aucune raison de ne pas utiliser l'élément "a" à la place. Vous avez juste besoin de spécifier (en css) "display: block" pour que vous puissiez le concevoir comme vous le feriez avec un div.

<style type="text/css"> 

.tools { 
    background-color:#aaa; 
    padding:5px; 
    display:block; 
} 

.tools span { 
    background-color:green; 
    color:white; 
} 

.tools:hover { 
    background-color:#ccc; 
} 

.tools:hover span { 
    background-color:red; 

} 

.tools:active { 
    background-color:#333; 
    color:#fff; 
} 

.tools:active span { 
    background-color:blue; 
} 


</style> 

</head> 

<body onselectstart="return false;" > 
<a class="tools" style="width:100px; height:20px;"> 
<span> 
Hello world... 
</span> 
</a> 
</body> 
7

Il fonctionnera si vous utilisez balise <label> au lieu de <a>, ou si vous mettez un dans l'autre.

Questions connexes