IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Mise en page CSS Discussion :

couleur de fond ligne et cellule


Sujet :

Tableau en CSS

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Février 2006
    Messages
    235
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 235
    Points : 314
    Points
    314
    Par défaut couleur de fond ligne et cellule
    Bonjour,

    J'ai un problème pour une 'surcharge' de propriété... j'explique :

    Example :
    je souhaite pouvoir dire qu'une ligne d'une table soit rouge mais qu'une cellule particulière soit jaune...

    j'ai fait un petit exemple pour illustrer la chose :
    dans cette example la ligne 2 et bien en rouge mais la premiere cellule laquel j'ai attaché un css pour mettre en jaune reste en rouge

    y a t'il moyen de regler ce probleme ? merci d'avance !!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitled Document</title>
        <style type="text/css">
    <!--
     
    #itemrows { border: 1px solid #777; margin: 0; padding: 0; display: block; }
    #itemrows h2 { font-weight:normal; display: inline; margin: 0; font-size:10px;}
    #itemrows th { border: 1px solid #aaa; background-color: #003399; color: #fff; text-align: center; padding: 0.25em; font-size: 110%; }
    #itemrows td {border: 1px solid #000; padding: 0.4em; }
    #itemrows .Redrow td {border-top: 5px solid #000; border-bottom: 5px solid #000; padding: 0.4em; background-color:red; }
    #itemrows .boldleft { border-left: 5px solid #000; padding: 0.4em; }
    #itemrows .boldright { border-right: 5px solid #000; padding: 0.4em; }
     
    .testJaune td{background-color:yellow;}
     
    -->
    </style>
    </head>
    <body>
        <table id="itemrows" width="75%" cellspacing="0">
            <tr>
                <th scope="col">
                    Column 1</th>
                <th scope="col">
                    Column 2</th>
                <th scope="col">
                    Column3</th>
            </tr>
            <tr>
                <td>
                    row1</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr class="Redrow">
                <td class="testJaune" >
                    row2</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    row3</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    row4</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </body>
    </html>

  2. #2
    Modérateur
    Avatar de Bisûnûrs
    Profil pro
    Développeur Web
    Inscrit en
    Janvier 2004
    Messages
    9 868
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Janvier 2004
    Messages : 9 868
    Points : 16 258
    Points
    16 258
    Par défaut
    Ton CSS est faux.

    Tu mets :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    .testJaune td{background-color:yellow;}
    Il faudrait mettre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    .testJaune{background-color:yellow;}
    ou

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    td.testJaune{background-color:yellow;}
    Tu disais à la balise td qui se trouvais dans celle dont la classe est testJaune de se mettre en jaune, seulement ta balise td ne comporte pas de balise td.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Février 2006
    Messages
    235
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 235
    Points : 314
    Points
    314
    Par défaut
    Ok, merci de ton eclaircissement ! J'ai effectivement mal utilisé les styles...
    Cependant, après correction ma première cellule de ma ligne rouge n'apparait toujours pas en jaune ?!

    Ce que je souhaite faire est il possible ???

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitled Document</title>
        <style type="text/css">
    <!--
     
    #itemrows { border: 1px solid #777; margin: 0; padding: 0; display: block; }
    #itemrows h2 { font-weight:normal; display: inline; margin: 0; font-size:10px;}
    #itemrows th { border: 1px solid #aaa; background-color: #003399; color: #fff; text-align: center; padding: 0.25em; font-size: 110%; }
    #itemrows td {border: 1px solid #000; padding: 0.4em; }
    #itemrows .Redrow td {border-top: 5px solid #000; border-bottom: 5px solid #000; padding: 0.4em; background-color:red; }
    #itemrows .boldleft { border-left: 5px solid #000; padding: 0.4em; }
    #itemrows .boldright { border-right: 5px solid #000; padding: 0.4em; }
     
    .testJaune {background-color:yellow;}
     
    -->
    </style>
    </head>
    <body>
        <table id="itemrows" width="75%" cellspacing="0">
            <tr>
                <th scope="col">
                    Column 1</th>
                <th scope="col">
                    Column 2</th>
                <th scope="col">
                    Column3</th>
            </tr>
            <tr>
                <td>
                    row1</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr class="Redrow ">
                <td class="testRed testJaune   ">
                    row2</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    row3</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    row4</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </body>
    </html>

  4. #4
    Membre expérimenté
    Avatar de kaiser59
    Homme Profil pro
    Inscrit en
    Novembre 2005
    Messages
    1 264
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 1 264
    Points : 1 350
    Points
    1 350
    Par défaut
    Salut,

    As-tu essayé ceci ?
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    #itemrows  .testJaune  {background-color: #ffff00;}

    ++

  5. #5
    Membre émérite
    Avatar de Candygirl
    Femme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    1 912
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 52
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 912
    Points : 2 907
    Points
    2 907
    Par défaut
    Citation Envoyé par kaiser59
    Salut,

    As-tu essayé ceci ?
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    #itemrows  .testJaune  {background-color: #ffff00;}
    ça ne suffira pas; ton sélecteur reste moins spécifique que celui pour définir la coleur rouge.

    Tu dois rajouter encore au minimum une balise. Par exemple:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    #itemrows  td.testJaune  {background-color: #ffff00;}
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    table#itemrows  .testJaune  {background-color: #ffff00;}
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    body #itemrows  .testJaune  {background-color: #ffff00;}
    ou encore
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    #itemrows  .Redrow .testJaune  {background-color: #ffff00;}
    ,...

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Février 2006
    Messages
    235
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2006
    Messages : 235
    Points : 314
    Points
    314
    Par défaut
    Ok merci de votre aide j'ai reussi à avoir ce que je souhaitais !
    (Sympa la doc je l'ai ajouter dans mes favoris )

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [WD17] couleur de fond d'une cellule ou d'une ligne
    Par labib23dz dans le forum WinDev
    Réponses: 6
    Dernier message: 01/10/2013, 18h50
  2. Modifier couleur de fond d'une cellule d'un tableau dynamiquement.
    Par fred61 dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 27/03/2009, 02h19
  3. Couleur de fond d'une cellule variable
    Par Cafu3 dans le forum Débuter
    Réponses: 2
    Dernier message: 19/03/2009, 10h56
  4. [VB.NET][DataGridView]:couleur de fond d'une cellule
    Par BigTicket42 dans le forum Windows Forms
    Réponses: 8
    Dernier message: 13/05/2008, 22h07
  5. mise à jour de la couleur de fond d'une cellule
    Par Lady_jade dans le forum Général JavaScript
    Réponses: 10
    Dernier message: 02/11/2005, 11h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo