HTML Academy
On-hover effects: buttons, part 3
2D Transforms25/32
Back to the list of tasks
  • 1. Moving objects horizontally
  • 2. Moving objects vertically
  • 3. Fireball training
  • 4. Increasing and decreasing the size
  • 5. Defending the city
  • 6. The beginning of the journey
  • 7. The maze
  • 8. The battle, part 1
  • 9. The battle, part 2
  • 10. Test: The mysterious card
  • 11. The battle, part 3
  • 12. Test: The shattered crystal
  • 13. The final battle
  • 14. Features of transform-origin, part 1
  • 15. Features of transform-origin, part 2
  • 16. Features of transform-origin, part 3
  • 17. Features of transform-origin, part 4
  • 18. Centering with transform: translate
  • 19. Rotating the text in blocks
  • 20. Rotating the text in the background
  • 21. Custom shadows
  • 22. On-hover effects: buttons, part 1
  • 23. On-hover effects: buttons, part 2
  • 24. On-hover effects: buttons, part 3
  • 25. On-hover effects: the gallery
  • 26. The “stack” of cards
  • 27. Preparing the round menu
  • 28. Round menu, step 1
  • 29. Round menu, step 2
  • 30. Round menu, step 3
  • 31. The round menu, final part
  • 32. Test: Arranging the cards
The “stack” of cards
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

On-hover effects: the gallery

In any situation, when you need to smoothly change the position or size of a block or to modify something about its external appearance using whatever available method, you have a choice: use the transition + transform combination or use Javascript to dynamically change the width/height and object coordinates in the script.

Often, the choice will be in favor of making such changes in Javascript using the jQuery library, but in most cases you can create simple visual effects using just pure CSS, and it is much more powerful than similar jQuery functions. In addition, in some cases, certain transforms in CSS may not only utilize the CPU of the computer or mobile device, but also the resources of the graphics card, which makes it possible to offload tasks from the processor and get rid of effect “lag” in order to improve performance.

In this assignment, let’s utilize transforms and smooth transitions to create a simple mini-gallery of images that enlarge and become semi-transparent when the user hovers the mouse over them.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>On-hover effects: the gallery</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <ul class="deck"> <li><img class="ten" src="cards/10.png" alt="Ten"></li> <li><img class="queen" src="cards/queen.png" alt="Queen"></li> <li><img class="king" src="cards/king.png" alt="King"></li> <li><img class="ace" src="cards/ace.png" alt="Ace"></li> <li><img class="ten" src="cards/10.png" alt="Ten"></li> <li><img class="jack" src="cards/jack.png" alt="Jack"></li> <li><img class="queen" src="cards/queen.png" alt="Queen"></li> </ul> </body> </html>
CSS
body { margin: 0; padding: 0; background-color: #f5f5f5; } .deck { list-style: none; } .deck > li { position: relative; display: inline-block; margin: 0 20px 20px 0; } .deck img { width: 100px; transition: all 0.1s linear; } .deck img:hover { }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. For .deck img:hover, assign the value 0.6 to opacity.
    2. Also increase scale to the value 1.1.

    After you complete every change, hover the cursor over any card to check your work.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.