Animer une image en CSS
Ce code était utilisé dans la galerie photo.
Le code HTML
Code HTML (Code à insérer dans le page) (19 lignes)
Le code LESS
Code LESS (Style à compiler) (107 lignes)
@bookThumbSpace:40px; html:not(.no-details) .brol-t-next a{ background-image:url("https://www.gaudry.be/photo-rf-044060550502405919118114.jpg"); } .no-details{ .brol-t-thumb a span{ display:none; } } html:not(.no-details){ .brol-t-next{ float:right; padding-right:@bookThumbSpace; } .brol-t-prev{ float:left; padding-left:@bookThumbSpace; } .brol-t-thumb { width: 150px; height: 150px; margin: @bookThumbSpace auto 10px; perspective: 1000px; } .brol-t-thumb:hover{ perspective: 0px; } brol-t-thumb:before, .brol-t-thumb, .brol-t-thumb:after { box-sizing: initial; } .brol-t-thumb a { display: block; width: 100%; height: 100%; background-size: 150px, cover; transform-style: preserve-3d; transition: all 0.5s; transform: rotateX(80deg); } .brol-t-thumb:hover a { transform: rotateX(0deg); transform-origin: bottom; } .brol-t-thumb a:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); transition: all 0.5s; box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5); opacity: 1; transform: rotateX(0) translateZ(-60px) scale(0.85); } .brol-t-thumb img { display: none; } .brol-t-thumb:hover a:before { opacity: 0.50; box-shadow: 0 0 50px 50px rgba(0, 0, 0, 0.5); transform: rotateX(95deg) translateZ(-80px) scale(0.75); transform-origin: bottom; } .brol-t-thumb a:after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 36px; background: inherit; background-size: cover, cover; background-position: bottom; transform: rotateX(90deg); transform-origin: bottom; } .brol-t-thumb a span { background-color: rgb(59, 80, 85, 0.5);/* the book cover*/ color: white; text-transform: uppercase; position: absolute; top: 100%; left: 0; width: 100%; font: bold 12px/36px "Open Sans"; text-align: center; transform: rotateX(-89.99deg); transform-origin: top; z-index: 1; visibility:visible; } .brol-t-thumb:hover a span { visibility:hidden; } }
Le code CSS
Code css (Style à insérer) (94 lignes)
html:not(.no-details) .brol-t-next a { background-image: url("https://www.gaudry.be/photo-rf-044060550502405919118114.jpg"); } .no-details .brol-t-thumb a span { display: none; } html:not(.no-details) .brol-t-next { float: right; padding-right: 40px; } html:not(.no-details) .brol-t-prev { float: left; padding-left: 40px; } html:not(.no-details) .brol-t-thumb { width: 150px; height: 150px; margin: 40px auto 10px; perspective: 1000px; } html:not(.no-details) .brol-t-thumb:hover { perspective: 0px; } html:not(.no-details) brol-t-thumb:before, html:not(.no-details) .brol-t-thumb, html:not(.no-details) .brol-t-thumb:after { box-sizing: initial; } html:not(.no-details) .brol-t-thumb a { display: block; width: 100%; height: 100%; background-size: 150px, cover; transform-style: preserve-3d; transition: all 0.5s; transform: rotateX(80deg); } html:not(.no-details) .brol-t-thumb:hover a { transform: rotateX(0deg); transform-origin: bottom; } html:not(.no-details) .brol-t-thumb a:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); transition: all 0.5s; box-shadow: 0 0 25px 25px rgba(0,0,0,0.5); opacity: 1; transform: rotateX(0) translateZ(-60px) scale(0.85); } html:not(.no-details) .brol-t-thumb img { display: none; } html:not(.no-details) .brol-t-thumb:hover a:before { opacity: 0.50; box-shadow: 0 0 50px 50px rgba(0,0,0,0.5); transform: rotateX(95deg) translateZ(-80px) scale(0.75); transform-origin: bottom; } html:not(.no-details) .brol-t-thumb a:after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 36px; background: inherit; background-size: cover, cover; background-position: bottom; transform: rotateX(90deg); transform-origin: bottom; } html:not(.no-details) .brol-t-thumb a span { background-color: rgba(59,80,85,0.5); color: white; text-transform: uppercase; position: absolute; top: 100%; left: 0; width: 100%; font: bold 12px/36px "Open Sans"; text-align: center; transform: rotateX(-89.99deg); transform-origin: top; z-index: 1; visibility: visible; } html:not(.no-details) .brol-t-thumb:hover a span { visibility: hidden; }
Version en cache
21/12/2024 17:16:07 Cette version de la page est en cache (à la date du 21/12/2024 17:16:07) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 04/01/2014, dernière modification le 02/04/2020
Source du document imprimé : https://www.gaudry.be/css-effet-image-survol-perspective.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.