HTML Academy
Rotating the text in the background
2D Transforms21/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
On-hover effects: buttons, part 1
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Custom shadows

Sometimes you need to implement shadows that differ from the standard box-shadow without using images.

For example, shadows that are skewed in various directions.

It is impossible to do this using box-shadow. Therefore, you need to use a more complex technique:

  • Let’s create two blocks with regular shadows using the before and after pseudoelements.
  • Let’s skew these blocks using rotate
  • Let’s assign them a negative z-index.

This will move the boxes with shadows under the parent container so that only parts of the shadows will face outwards.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Custom shadows</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="shadow-box"> <h3>Block with shadows</h3> </div> </body> </html>
CSS
body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: "Arial Narrow", "Arial", sans-serif; } .shadow-box { position: relative; width: 400px; height: 100px; margin: 50px auto; padding: 100px 0; text-align: center; background-color: white; box-shadow: 0 0 3px #cccccc; } .shadow-box::before, .shadow-box::after { content: ""; position: absolute; top: 80%; bottom: 15px; width: 45%; max-width: 300px; background-color: #dddddd; box-shadow: 0 15px 10px #555555; } .shadow-box::before { left: 10px; } .shadow-box::after { right: 10px; }

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. Rotate the before pseudoelement of the shadow-box block 3° counterclockwise.
    2. Then rotate the after pseudoelement clockwise 3°.
    3. Assign both pseudo-elements a z-index that is equal to -1.

    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.