« CSS » : différence entre les versions

De bricosoft
 
m Remplacement des balises <source> obsolètes par <syntaxhighlight> (bot)
 
(Une version intermédiaire par un autre utilisateur non affichée)
Ligne 1 : Ligne 1 :
<div class="thumb tleft"><google uid="C06" position="left"></google></div>
<div class="thumb tright">{{#widget:Twitter Search |query=#{{PAGENAME}} |title=Bricosoft.com/{{PAGENAME}} |caption=Ce que les gens disent sur {{PAGENAME}} }}</div>
'''CSS''' s'approche plus du Content Scrambling System que du Cascading Style Sheet.
'''CSS''' s'approche plus du Content Scrambling System que du Cascading Style Sheet.


Ligne 6 : Ligne 4 :


Pour un sticky footer, il faut en premier sortir le div footer du DOM principal :
Pour un sticky footer, il faut en premier sortir le div footer du DOM principal :
<source lang="html4strict">
<syntaxhighlight lang="html4strict">
...
...
</head>
</head>
Ligne 18 : Ligne 16 :
</body>
</body>
</html>
</html>
</source>
</syntaxhighlight>


Son style :
Son style :
<source lang="css">
<syntaxhighlight lang="css">
#ft {
#ft {
position: relative;
position: relative;
Ligne 28 : Ligne 26 :
clear: both;
clear: both;
}
}
</source>
</syntaxhighlight>


== px vs em vs pt vs %==
== px vs em vs pt vs %==
Ligne 39 : Ligne 37 :
*background-color
*background-color
*background-image
*background-image
<source lang="css">
<syntaxhighlight lang="css">
background-image:url('paper.gif');
background-image:url('paper.gif');
</source>
</syntaxhighlight>
*background-repeat
*background-repeat
*background-attachment
*background-attachment
Ligne 49 : Ligne 47 :


Dans l'ordre décroissant de performances :
Dans l'ordre décroissant de performances :
<source lang="css">
<syntaxhighlight lang="css">
/* par ID ★★★ */
/* par ID ★★★ */
#trucmuche {...}
#trucmuche {...}
Ligne 64 : Ligne 62 :
/* universel */
/* universel */
* {...}
* {...}
</source>
</syntaxhighlight>


Bonnes pratiques :
Bonnes pratiques :
<source lang="css">
<syntaxhighlight lang="css">
/* ID */
/* ID */
#boutonRetour {…}
#boutonRetour {…}
Ligne 78 : Ligne 76 :
.classement-important {…}
.classement-important {…}


</source>
</syntaxhighlight>


A éviter :
A éviter :
<source lang="css">
<syntaxhighlight lang="css">
/* le tag html avant id */
/* le tag html avant id */
button#boutonRetour {…}
button#boutonRetour {…}
Ligne 87 : Ligne 85 :
/* une classe + id */
/* une classe + id */
.classement-important#iconMenu {…}
.classement-important#iconMenu {…}
</source>
</syntaxhighlight>


*sources : [https://developer.mozilla.org/en/Writing_Efficient_CSS dev.moizilla.org]
*sources : [https://developer.mozilla.org/en/Writing_Efficient_CSS dev.moizilla.org]

Dernière version du 8 novembre 2026 à 17:46

CSS s'approche plus du Content Scrambling System que du Cascading Style Sheet.

stickyfooter / pied-de-page collé

Pour un sticky footer, il faut en premier sortir le div footer du DOM principal :

...
</head>
<body>
  <div class="principal">
  ... plein de trucs supers
  </div>
  <div id="ft">
    <p>Footer.</p>
  </div>
</body>
</html>

Son style :

#ft {
	position: relative;
	margin-top: -100px;
	height: 100px;
	clear: both;
}

px vs em vs pt vs %

  • px : reliable but not for printing
  • em : reliable and depends on browsers
  • pt : for printing
  • % : depends on browsers

background

  • background-color
  • background-image
background-image:url('paper.gif');
  • background-repeat
  • background-attachment
  • background-position

Performances

Dans l'ordre décroissant de performances :

/* par ID ★★★ */
#trucmuche {...}
body.superclass #totoche {...}

/* par classe ★★ */
.bavette {...}
ul ol a.cerveau {...}

/* par tag ★ */
ul {...}
ul li a {...}

/* universel */
* {...}

Bonnes pratiques :

/* ID */
#boutonRetour {…}

#iconMenu {…}

/* classe */
.cellule-rouge {…}
/* encore plus classe avec sémantique */
.classement-important {…}

A éviter :

/* le tag html avant id */
button#boutonRetour {…}

/* une classe + id */
.classement-important#iconMenu {…}

Liens