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; }
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 04/01/2014, last modified the 02/04/2020
Source of the printed document:https://www.gaudry.be/en/css-effet-image-survol-perspective.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.