28220 sujets

CSS et mise en forme, CSS3

Bonjour

Voilà le code :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://www.w3.org/StyleSheets/TR/W3C-REC.css" type="text/css"?>
<?xml-stylesheet href="#internalStyle" type="text/css"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Example</title>
<style type="text/css" id="internalStyle">
#element1:hover + #element2 { background:#f00 }
</style>
</head>
<body>
<div id="element1">plop</div>
<div id="element2">plop</div>
</body>
</html>


De cette façon, lors du survol de l'élement1, j'applique un style à l'élement2. Mais comme faire l'inverse rien qu'en CSS ?

Merci Smiley smile