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 :

Effets de bord avec des animations en pur CSS


Sujet :

Animation en CSS

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2020
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2020
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Effets de bord avec des animations en pur CSS
    Bonjour,

    Je suis étudiant en IT et donc j'apprends, merci de votre compréhension.
    Effectuant actuellement un projet portant surtout sur le back (php) je voulais allez un peu plus vite en partant de templates pur CSS (pas de JS) pour le front.
    Mon but était de faire un background animé (diapo avec fondu enchainé), un header avec un menu horizontal fixe et un footer fixe également.
    Le tout n’est pas trop mal sauf que mon contenu de site hérite des propriétés de ma classe .crossfade et donc apparait et disparait en fondu enchainé.

    Je ne comprends pas pourquoi cela se produit vu que mon <div class="crossfade"> et ouvert et refermé au début de mon body. Je n'ai pas détecter non plus l'origine du problème dans le CSS.
    Quelqu'un pourrait-il donc éclairer ma lanterne siou'plait ?
    Merci d'avance a vous tous !
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    <!DOCTYPE html>
    <html>
        <head>
            <title>TODO supply a title</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <LINK REL=StyleSheet HREF="Style.css" TYPE="text/css">
     
        </head>
        <body>
            <div class="crossfade">
                <figure></figure>
                <figure></figure>
                <figure></figure>
                <figure></figure>
            </div>    
            <header id="header">
                <nav class="links" style="--items: 5;">
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                    <a href="#">Link 3</a>
                    <a href="#">Link 4</a>
                    <a href="#">Link 5</a>
                    <span class="line"></span>
                </nav>
            </header>
            <div class="content">
                All links need is here <br/>
                <strong>Pros</strong>
                <ul>
                    <li>It's pure CSS.</li>
                </ul>
                <strong>Cons</strong>
                <ul>
                    <li>It's pure CSS.</li>
                </ul>
     
            </div>
            <footer id="footer">
                <ul>
                    <li>En utilisant ce site vous accepter sans reserve les <a href="cgu.html">CGU/CGV</a></li>
                    <li><a href="contact.html">Contactez nous !</a></li>
                </ul>
            </footer>
        </body>
    </html>


    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
    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
    @import url('https://fonts.googleapis.com/css?family=Inconsolata|Lato:300,400,700');
    * {
      padding: 0;
      margin: 0
    }
     
    .crossfade > figure {
      animation: imageAnimation 32s linear infinite 0s;
      backface-visibility: hidden;
      background-size: cover;
      background-position: center center;
      color: transparent;
      height: 100%;
      left: 0px;
      opacity: 0;
      position: absolute;
      top: 0px;
      width: 100%;
      z-index: 0;
    }
     
    .crossfade > figure:nth-child(1) {
      background-image: url('./images/001.jpg');
    }
    .crossfade > figure:nth-child(2) {
      animation-delay: 8s;
      background-image: url('./images/002.jpg');
    }
    .crossfade > figure:nth-child(3) {
      animation-delay: 16s;
      background-image: url('./images/003.jpg');
    }
    .crossfade > figure:nth-child(4) {
      animation-delay: 24s;
      background-image: url('./images/004.jpg');
    }
     
    @keyframes imageAnimation {
      0% {
        animation-timing-function: ease-in;
        opacity: 0;
      }
      8% {
        animation-timing-function: ease-out;
        opacity: 1;
      }
      17% {
        opacity: 1
      }
      25% {
        opacity: 0
      }
      100% {
        opacity: 0
      }
    }
    html, body, h1, h2, h3, h4, h5, h6, p, li, ol, ul, pre {
    	margin: 0;
    	padding: 0;
    }
    html, body { min-height: 100%; }
     
    body {
    	background-color: #000000;;
    	color: #eee;
    	font-family: 'Lato', sans-serif;
    	font-size: 62.5%;
    	padding: 0 20px;
    	box-sizing: border-box;
    }
    code {
    	background: #fff1;
    	font-family: 'Inconsolata', monospace;
    	padding: .2em .4em;
    }
     
    .content {
    	background-color: #fff;
    	border-radius: 8px;
    	box-sizing: border-box;
    	color: #666;
    	font-size: 1.6em;
    	line-height: 1.4em;
    	margin: 20px auto;
    	margin-top: 80px;
    	padding: 20px;
    	width: 100%;
    	max-width: 800px;
    }
    .content ul {
    	margin: .5em 2em;
    	padding: 0;
    }
     
    #footer {
    	background-color: #246c;
    	background-image: linear-gradient(to bottom, transparent, #0009);
    	border-top: 1px solid #fff3;
    	box-shadow: inset 0 1px 0 #fff3, 0 0 32px #000;
    	overflow: hidden;
    	padding: 8px;
    	position: fixed;
    	left: 0;
    	right: 0;
    	bottom: 0;
    	z-index: 9001;
    }
    #footer a {
    	color: #85c6f6;
    	padding: 1em 0;
    	text-decoration: none;
    }
    #footer ul {
    	display: flex;
    	list-style: none;
    	justify-content: center;
    	font-size: 2em;
    	font-weight: 300;
    }
    #footer ul li {
    	padding: 0 .5em;
    }
     
    /* Appearance */
    .links {
    	background-color: #123;
    	background-image: linear-gradient(to bottom, #0003, transparent);
    	border-bottom: 2px solid #0003;
    	box-shadow: 0 0 32px #0003;
    	font-size: 2em;
    	font-weight: 300;
    }
    .links > a {
    	color: #9ab;
    	padding: .75em;
    	text-align: center;
    	text-decoration: none;
    	transition: all .5s;
    }
    .links > a:hover {
    	background: #ffffff06;
    	color: #adf;
    }
    .links > .line {
    	background: #68a;
    	height: 1px;
    	pointer-events: none;
    }
     
    /* The Magic */
    #header {
    	position: fixed;
    	top: 0;
    	left: 0;
    	right: 0;
    }
    .links {
    	display: grid;
    	grid-template-columns: repeat(var(--items), 1fr);
    	position: relative;
    }
    .links > .line {
    	opacity: 0;
    	transition: all .5s;
    	position: absolute;
    	bottom: 0;
    	left: var(--left, calc(100% / var(--items) * (var(--index) - 1)));
    	width: var(--width, calc(100% / var(--items)));
    	--index: 0;
    }
    .links > a:hover ~ .line {
    	opacity: 1;
    }
     
    .links > a:nth-of-type(1):hover ~ .line { --index: 1; }
    .links > a:nth-of-type(2):hover ~ .line { --index: 2; }
    .links > a:nth-of-type(3):hover ~ .line { --index: 3; }
    .links > a:nth-of-type(4):hover ~ .line { --index: 4; }
    .links > a:nth-of-type(5):hover ~ .line { --index: 5; }
    .links > a:nth-of-type(6):hover ~ .line { --index: 6; }
    .links > a:nth-of-type(7):hover ~ .line { --index: 7; }
    .links > a:nth-of-type(8):hover ~ .line { --index: 8; }
    .links > a:nth-of-type(9):hover ~ .line { --index: 9; }
    .links > a:nth-of-type(10):hover ~ .line { --index: 10; }
    .links > a:last-of-type:hover ~ .line { --index: var(--items); }

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

    je n'ai pas vraiment d'explication...
    Mais ça peut se corriger avec :
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    .crossfade > figure {
    ...
      z-index: -1;
    }

    Je t'invite aussi à lire cet article : Diaporama avec effet fade in/out - full CSS

    Pour un meilleur fondu-enchainé :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    @keyframes imageAnimation {
      0%, 100% {
        opacity: 0;
      }
      8.33% {
        opacity: 1;
      }
      25% {
        opacity: 1;
      }
      33.33% {
        opacity: 0;
      }
    }
    Dernière modification par Invité ; 29/02/2020 à 10h15.

  3. #3
    Modérateur

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

    Informations forums :
    Inscription : Janvier 2011
    Messages : 16 959
    Points : 44 122
    Points
    44 122
    Par défaut
    Bonjour,
    je n'ai pas vraiment d'explication...
    l'opacité influe sur le contexte d'empilement et l'ordre dans celui-ci.

    Pour plus de détails : Ce que personne ne vous a jamais dit à propos de z-index

    Une autre solution serait de mettre ton élément <div class="content"> en position:relative.

Discussions similaires

  1. Créez des tooltips en pur CSS avec hint.css
    Par FirePrawn dans le forum Mise en page CSS
    Réponses: 1
    Dernier message: 22/02/2013, 13h08
  2. effet de bord avec les commentaires //
    Par awalter1 dans le forum Langage
    Réponses: 5
    Dernier message: 10/04/2012, 08h57
  3. Problème avec des animations hors cadre !
    Par Skangell dans le forum Flash
    Réponses: 1
    Dernier message: 17/11/2010, 19h11
  4. Réponses: 0
    Dernier message: 29/04/2010, 15h04
  5. Réponses: 4
    Dernier message: 03/02/2009, 19h47

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