• Aucun résultat trouvé

Technologies web : Le langage CSS

N/A
N/A
Protected

Academic year: 2021

Partager "Technologies web : Le langage CSS"

Copied!
21
0
0

Texte intégral

(1)

T

ECHNOLOGIES WEB

CHAPITRE

II : L

E LANGAGE

CSS

Mme Amani JARRAYA

(2)

P

LAN

 Définition  Ecriture du CSS  Sélecteur  Notion de classe  Notion d’un ID  Mode page  Convention  Police de caractère  Apparence des listes  Arrière plan

2

(3)

D

ÉFINITION

(1/2)

CSS est l'abréviation de « Cascading Style Sheets »

• Les feuilles de style sont des ajouts de code au langage XHTML qui vont prendre en charge la présentation de la page Web

 Police, taille de caractères, interlignes, etc.

• Le concept du CSS repose sur le principe de la séparation du contenu et de la présentation

(4)

D

ÉFINITION

(2/2)

4

Lacune XHTML

Une taille de caractère limités à quelques valeurs (hx) Un seul modèle de bordure de tableaux

Une image d’arrière obligatoirement répétée en mosaïque

Utilité de CSS

CSS apportent de nombreuses possibilités de présentation

 Taille de caractères illimitée, de nouvelles présentation de

bordure, le contrôle d’interligne, le positionnement précis des images…

 Il simplifie le code

 Il facilite la maintenance du site

(5)

E

CRITURE DU

CSS (1/2)

Deux possibilité :

Interne : le code de la feuille de style sera placé dans l’entête du document XHTML

(6)

E

CRITURE DU

CSS (2/2)

6

Deux possibilité :

Externe: Regrouper les déclarations de style dans un fichier (.css) externe au fichier XHTML et mis dans le même répertoire que ce dernier.

Ma_Presentation.css

La balise <LINK> avertit le navigateur qu'il doit chercher un document situé à

l'extérieur de la page HTML.

L'attribut rel="stylesheet" précise que le document en question est une feuille de style

externe.

L'attribut type="text/css" précise le type de feuille de style.

(7)

S

ÉLECTEUR

Sélecteur { Propriété 1: valeur; Propriété 2 : valeur; Propriété N : valeur; }

(8)

N

OTION DE CLASSE

8 Définition de la classe

.

nom_de_classe { Propriété 1: valeur; } EX: .eni { font-family: Verdana; } Appel de la classe

<balise class=« nom_de_classe »>

EX: <p class=« eni »> … </p>

(9)

N

OTION D

UN

ID

Définition d’un id #nom_de_id { Propriété 1: valeur; } EX: #eni { font-family: Verdana; } Appel de la classe

<balise id=« nom_de_id»>

(10)

M

ODE PAGE

10 Définition table { Propriété 1: valeur; }

 Propriété1 s’exécutent pour tous les tableaux qui existent sur cette page

Il est possible d’affecter le même effet à des différents sélecteurs.

EX:

div

,

table

,

spam, h1 {

Propriété 1: valeur;

}

(11)

C

ONVENTION

 Commentaires

/* Ceci est un commentaire */

 Le code CSS et XHTML doit être écrit en

(12)

P

OLICE DE CARACTÈRE

(1/5)

12

Nom de la police

Font-family: nom de la police; Exemples:

• Font-family: Arial;

• Font-family: ‘courier New’; Italique

Font-style: italic ou oblique; Petite majuscule

Font-variant: small-caps;

(13)

P

OLICE DE CARACTÈRE

(2/5)

Gras Font-weight: bold; Taille: Font-size: valeur en pt ou px; Raccourci:

P {font: italic bold small-caps 24 pt Arial, sans-serif;}

(14)

P

OLICE DE CARACTÈRE

(3/5)

14

Couleur du texte

Color: red; Color: #ff0000; Décoration Text-decoration: underline; Transformation Text-transform: capitalize; Text-transform: uppercase; Text-transform: lowercase; Text-transform: none;

(15)

P

OLICE DE CARACTÈRE

(4/5)

Espace entre les lignes

Line-height: 2; ou

Line-height: 200%; (double interligne) Line-height: 18px; Alignement horizontal Text-align: left; Text-align: right; Text-align: center; Text-align: justify;

(16)

P

OLICE DE CARACTÈRE

(5/5)

16 Alignement vertical Vertical-align: sub; Vertical-align: sup; Vertical-align: top; Vertical-align: middle;

Longueur et hauteur (en px ou en pourcentage) Width: 235px;

Hight: 50%;

(17)

A

PPARENCE DES LISTES

Apparence des puces et des numérotations

List-style-type: disc; (cercle plein) List-style-type: circle; (cercle)

List-style-type: square; (carré)

List-style-type: decimal; (1, 2, 3, etc.)

List-style-type: upper-roman; (I, II, III,…) List-style-type: lower-roman; (i, ii, iii, etc.) List-style-type: upper-alpha; (A, B, C,...) List-style-type: lower_alpha; (a, b, c, etc.)

Puces graphiques

List-style-image: url(votre_puce.gif);

(18)

E

XERCICE

1

18

(19)

A

RRIÈRE PLAN

(1/2 )

Couleur d’arrière-plan

Body {background-color: #99ccff;} H2 {background-color: #99ccff;} Insertion et répétition d’une image

Background-image: url(image.jpeg); Background-repeat: repeat; Background-repeat: repeat-x; Background-repeat: repeat-y; Background-repeat: no-repeat; Exemple:

(20)

background-A

RRIÈRE PLAN

(2/2 )

20

Positionnement de l’image

 Background-position: 50px 100px; (axe horizontal

par rapport au bord gauche , axe vertical par rapport au bord supérieur)

 Background-position: 20% 50%; (axe horizontal

par rapport au bord gauche , axe vertical par rapport au bord supérieur)

 Background-position: center left; (position

horizontale, position verticale) Défilement de l’image

 Background-attachment: scroll; (défilement de

l’image)

 Background-attachment: fixed;

(21)

Références

Documents relatifs

The advantage of the proposed methods with respect to previous ones using exact formal concepts [2,4,11], is that by only selecting approximate formal concepts associated to

A UN meeting today is discussing happiness, which doesn't come in dollar bills but - says a report - from strong social networks, employment, health, political freedom and the absence

Robert Dane, Solar Sailor's founder, says that the technology offers ship owners huge fuel savings and could be used on all types of vessels.. You're out there on the water and

By the end of 2015 more than 100,000 Brazilians – half of them undergraduates, the other half doctoral students – will have spent a year or so abroad at the best

Automated driving of this sort is still far into the future but the automated parking feature on the EN-Vs could be used at places like shopping centres, for example.. Drivers

technologies such as radio-frequency identification, sensor networks, tiny embedded servers, and energy harvesters — all connected to the next-generation internet using

(…) One of the world's top experts on diseases connected to smoking has complained to the National Theatre in London that he was shocked to witness members of the cast smoking

choices between letters, phonemes, morphemes, words, syntactic struc- tures, and textual and discoursal structures, including metrical and literary ones, as well as