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 :

Alignement vertical d'éléments avec CSS


Sujet :

Positionnement en CSS

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Points : 20
    Points
    20
    Par défaut Alignement vertical d'éléments avec CSS
    Bonjour,

    je suis une bille finie en HTML et CSS, mais cette fois je me soigne

    Voici donc mon problème:

    j'ai un menu de navigation dont je fournis le code ci-dessous.
    Je souhaite aligner 2 elements horizontalement et verticalement.

    Je n'y arrive pas

    voici ce que je souhaite
    Nom : wishes.png
Affichages : 122
Taille : 13,0 Ko
    et malheureusement ce que je produis
    Nom : produced.png
Affichages : 147
Taille : 13,6 Ko

    Merci pour vos eclaircissements sur la methode que j'ai employé, vous trouverez le code ci-dessous.
    On constatera que les decalages ne sont pas les mêmes à chaque fois et je ne comprend pas comment les elements sont affichés.

    Code html : 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
    <nav id="sideNav">
                <ul id="navigationMenu">
                    <h4>Gestion des incidents HVS</h4>
                    <li id="incident">
                        <a href="http://intraqual/intraqual_prod/Dynamic/xaccueil/cadre_form.aspx?idform=171">
                            <span class="incident navItem hvr-grow">Déclaration d'incidents</span>
                        </a>
                        <a href="M:\COMMUN\VIDEOS DYNAMIC\INCIDENT\Cpt_Pres_Incident_HVS_F.htm" target="_blank">
                            <span class="incident-demo demo hvr-grow">DEMO</span>
                        </a>
                    </li>
                    <li id="chute">
                        <a href="http://intraqual/intraqual_prod/dynamic/xAccueil/cadre_form.aspx?idform=175">
                            <span class="chute navItem hvr-grow">Déclaration de chutes</span>
                        </a>
                        <a><span class="chute-demo demo">DEMO</span></a>
                    </li>
                    <li id="improvement">
                        <a href="http://intraqual/intraqual_prod/Dynamic/xaccueil/cadre_form.aspx?idform=169">
                            <span class="improvement navItem hvr-grow">Proposition d'amélioration</span>
                        </a>
                        <a href="M:\COMMUN\VIDEOS DYNAMIC\AMELIORATION\Cpt_Amelioration_FD.htm" target="_blank"><span class="improvement-demo demo hvr-grow" >DEMO</span></a>
                    </li>
                    <h4>Accès aux autres modules</h4>
                    <li id="others">
                    	<a href="http://intraqual/intraqual_prod/Dynamic/xaccueil/cadre_form.aspx?idform=178" target="_blank">
                    		<span class="others navItem hvr-grow">Demande de nouvel <br> article HVS</span>
                    	</a>
                    	<a href="" target="_blank"><span class="others-demo demo hvr-grow" >DEMO</span></a>
                    </li>
                </ul>
            </nav>

    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    * {
        /* A universal CSS reset */
        margin: 0;
        padding: 0;
    }
     
    body {
        font-size: 14px;
        font-family: Arial, Helvetica, sans-serif;
        color: #fff;
    }
     
    h2 {
        font-size: 30px;
        font-weight: normal;
        padding: 40px 0 20px;
        margin-left: 10px;
    }
     
    h4 {
        font-weight: normal;
    }
     
    h1,
    h2,
    h3,
    h4 {
        color: #081071;
        font-family: "Myriad Pro", Arial, Helvetica, sans-serif;
        text-align: left;
        font-size: x-large;
        font-weight: bold;
    }
     
     
    h1 {
        font-size: 300%;
     
    }
     
    .hvr-grow {
        display: inline-block;
        vertical-align: middle;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0);
        backface-visibility: hidden;
        -moz-osx-font-smoothing: grayscale;
        transition-duration: 0.3s;
        transition-property: transform;
    }
     
    .hvr-grow:hover,
    .hvr-grow:focus,
    .hvr-grow:active {
        transform: scale(1.05);
    }
     
    #container {
        margin: 0 auto;
    }
     
    #sideNav {
        float: left;
        margin-left: 10px;
        height: 100%; 
        text-align: left;
    }
     
    #sideNav span.navItem {
        padding: 6px;
        padding-top: 20px;
        padding-bottom: 20px;
        display: block;
        color: white;
        word-wrap: break-word;
    }
     
    #sideNav span {
        padding: 5px;
        padding-bottom: 20px;
        display: block;
        color: white;
    }
     
    #sideNav a {
        text-decoration: none;
        display: inline-block;
    }
     
    #sideNav h4 {
        margin-top: 50px;
    }
     
    .navItem {
        margin: 10px;
        width: 200px;
    }
     
    .incident {
        border-radius: 5px;
        background: #33aae4;
    }
     
    .incident-demo {
        border-radius: 5px;
        background: #33aae4;
    }
     
    .incident:before {
        display: inline-block;
        width: 48px;
        height: 48px;
        margin-right: 5px;
        content: "";
        background: url("note.png") no-repeat 0 0;
        background-size: 100%;
        vertical-align: middle;
    }
     
    .chute {
        border-radius: 5px;
        background: #e47e33;
    }
     
    .chute-demo {
        border-radius: 5px;
        background: #e47e33;
        display: block;
    }
     
    .chute:before {
        display: inline-block;
        width: 48px;
        height: 48px;
        margin-right: 5px;
        content: "";
        background: url("first-aid.svg") no-repeat 0 0;
        background-size: 100%;
        vertical-align: middle;
    }
     
    .demo {
        font-size: xx-small;
        width: 32;
        height: 32;
    }
     
    .demo:before {
        display: block;
        width: 32;
        height: 32;
        content: "";
        background: url("play-icon.svg") no-repeat 0 0;
        background-size: 80%; 
    }
     
    .improvement {
        border-radius: 5px;
        background: #15c50a;
    }
     
    .improvement-demo {
        border-radius: 5px;
        background: #15c50a;
    }
     
    .improvement:before {
        display: inline-block;
        width: 48px;
        height: 48px;
        margin-right: 5px;
        content: "";
        background: url("heart.svg") no-repeat 0 0;
        background-size: 100%;
        vertical-align: middle;
    }
     
    .others {
        border-radius: 5px;
        background: #888;
    }
     
    .others-demo {
        border-radius: 5px;
        background: #888;
    }
     
    .others:before {
        display: inline-block;
        width: 48px;
        height: 48px;
        margin-right: 5px;
        content: "";
        background: url("hospital.svg") no-repeat 0 0;
        background-size: 100%;
        vertical-align: middle;
    }

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    16 952
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 16 952
    Points : 44 069
    Points
    44 069
    Par défaut
    Bonjour,
    une solution simple, parmi d'autres, serait d'ajouter sur tes liens le CSS suivant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    #sideNav a {
        display: table-cell;
        vertical-align: middle;    
    }

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Points : 20
    Points
    20
    Par défaut
    Merci, c'est effectivement simple et génial

    Si je peux abuser, le bouton demo n'a pas l'icone et le texte centré. Comment est-ce que je le corrige ?
    J'ai inséré l'icone avec un tag before, etait-ce le meilleur choix ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <a href="blabla" target="_blank"><span class="improvement-demo demo hvr-grow" >DEMO</span></a>
    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
     
    .demo {
        font-size: xx-small;
        width: 32;
        height: 32;
    }
     
    .demo:before {
        display: block;
        width: 32;
        height: 32;
        content: "";
        background: url("play-icon.svg") no-repeat 0 0;
        background-size: 80%; 
    }
     
    .improvement-demo {
        border-radius: 5px;
        background: #15c50a;
    }

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    :before s'appelle un "pseudo-élément" (voir la différence avec "pseudo-classe").

    Et oui, c'est une bonne idée.
    En position:absolute; c'est même mieux.

    On peut aller plus loin : http://codepen.io/jreaux62/pen/zvqgxR

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <ul>
      <li class="trophees"><a href="#">Les trophées</a></li>
      <li class="livres active"><a href="#">Les livres</a></li>
      <li class="news"><a href="#">Les news</a></li>
      <li class="faq"><a href="#">Les FAQ</a></li>
    </ul>
    Code css : 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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    ul {
      list-style: none;
      width: 20em;
    }
    li a {
      position: relative;
      display: block;
      text-align: center;
      padding:20px;
      padding-left:40px;
    }
     
    /* ICONES */
    li a:before {
      position: absolute;
      content: '';
      top: 50%; margin-top: -13px;
      left: 5px;
      width: 27px;
      height: 27px;
    }
    li.trophees a:before {
      background: url(http://www.developpez.net/forums/images/ranks/embleme-trophee1.png) no-repeat;
    }
    li.livres a:before {
      background: url(http://www.developpez.net/forums/images/ranks/embleme-redacteur.png) no-repeat;
    }
    li.news a:before {
      background: url(http://www.developpez.net/forums/images/ranks/embleme-chroniqueur.png) no-repeat;
    }
    li.faq a:before {
      background: url(http://www.developpez.net/forums/images/ranks/embleme-faq.png) no-repeat;
    }
     
    /* ANIMATION des TEXTES */
    li a {
      -webkit-transition: all 1s ease;
      -moz-transition: all 1s ease;
      -ms-transition: all 1s ease;
      -o-transition: all 1s ease;
      transition: all 1s ease;
    }
    li.active a,
    li:hover a {
      padding-right:40px;
      padding-left:10px;
    }
     
    /* ANIMATION des ICONES */
    li a:before {
      -webkit-transition: all 1s ease;
      -moz-transition: all 1s ease;
      -ms-transition: all 1s ease;
      -o-transition: all 1s ease;
      transition: all 1s ease;
    }
    li.active a:before,
    li:hover a:before {
      left:100%; margin-left: -37px;/*largeur icone + 10px*/
      -ms-transform: rotate(720deg);
      /* IE 9 */
      -webkit-transform: rotate(720deg);
      /* Chrome, Safari, Opera */
      transform: rotate(720deg);
    }
     
    /* un peu de déco.. */
    li a {
      font-family:arial,sans-serif;
      background: #eef;
      text-decoration: none;
      color:darkblue;
      font-weight: normal;
    }
    li:hover a,
    li.active a {
      background: #efe;
      color:green;
    }
    li.active a {
      font-weight: bold;
    }
    Dernière modification par Invité ; 28/10/2016 à 10h39.

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Points : 20
    Points
    20
    Par défaut
    merci pour ces details

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

Discussions similaires

  1. probleme de position avec css
    Par bouzakher dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 06/03/2009, 19h52
  2. probleme d'alignement avec IE6
    Par ChambreClaire dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 25/06/2008, 09h32
  3. [CSS&HTML]Problem de hauteur avec un tableau
    Par pierrot10 dans le forum Mise en page CSS
    Réponses: 4
    Dernier message: 27/09/2006, 19h21
  4. Probleme avec CSS : A IMG
    Par Seth77 dans le forum Mise en page CSS
    Réponses: 10
    Dernier message: 23/06/2006, 17h09
  5. Probleme avec CSS
    Par Rychi dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 16/03/2005, 18h26

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