Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Titre du document</title> <style> .example { position: relative; padding: 0; width: 300px; display: block; cursor: pointer; overflow: hidden; } .content { opacity: 0; font-size: 40px; position: absolute; top: 0; left: 0; color: #1c87c9; background-color: rgba(200, 200, 200, 0.5); width: 300px; height: 300px; -webkit-transition: all 400ms ease-out; -moz-transition: all 400ms ease-out; -o-transition: all 400ms ease-out; -ms-transition: all 400ms ease-out; transition: all 400ms ease-out; text-align: center; } .example .content:hover { opacity: 1; } .example .content .text { height: 0; opacity: 1; transition-delay: 0s; transition-duration: 0.4s; } .example .content:hover .text { opacity: 1; transform: translateY(250px); -webkit-transform: translateY(250px); } </style> </head> <body> <h2>Texte animé sur une image passée en survol</h2> <div class="example"> <img src="/uploads/media/default/0001/01/b408569013c0bb32b2afb0f0d45e93e982347951.jpeg" width="300" height="300" alt="tree" /> <div class="content"> <div class="text">Arbre</div> </div> </div> </body> </html>