HTML Academy
Challenge: Dim Shadows
Shadow Play10/17
Back to the list of tasks
  • 1. The box-shadow Property
  • 2. Horizontal Shadow Offset
  • 3. Vertical Shadow Offset
  • 4. Shadow Feathering
  • 5. Stretching the Shadow
  • 6. Feathering + Stretch
  • 7. Shadow Color
  • 8. Inner Shadow
  • 9. Challenge: Dim Shadows
  • 10. Semi-Transparent Shadow
  • 11. Casting a Shadow Only from One Side
  • 12. Multiple Shadows
  • 13. Multiple Borders for One Element
  • 14. Shadow Art – 1
  • 15. Shadow Art - 2
  • 16. Shadow Art - 3
  • 17. Challenge: The Foreboding Shadows
Casting a Shadow Only from One Side
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Semi-Transparent Shadow

If the shadow has a non-zero feathering radius, then it automatically becomes semi-transparent. But sometimes you need to make a semi-transparent shadow without a feathering radius (such as, for example, for buttons in your mini-browser).

To do this, you can use the new colors format for CSS, rgba. Example:

color: red;
color: #ff0000;
color: rgba(255, 0, 0, 0.5);

All of the color entries in the example are set to red, but the last entry is set to red with 50% transparency.

In rgba, the first three values specify the color, where they can be any integer between 0 and255. The last value specifies the transparency level and can be a fractional number of between 0 (full transparency) and 1.

You can set a semi-transparent color using rgba not only for shadows, but also for other properties with a color, including: frames, the background, and so on.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Semi-Transparent Shadow</title> <link rel="stylesheet" href="style.css"> </head> <body> <button class="btn btn1" type="button">Feed</button> <button class="btn btn2" type="button">Chase</button> </body> </html>
CSS
.btn1 { box-shadow: 0 0 0 15px #27ae60; } .btn2 { box-shadow: 0 0 0 15px #e74c3c; } body { padding-top: 200px; background: url("muffin.jpg") no-repeat 40% 0; background-size: auto 700px; font-size: 18px; font-family: "Tahoma", sans-serif; } .btn { display: block; margin: 50px auto; padding: 15px 20px; width: 150px; border: none; box-sizing: content-box; background-color: #2c3e50; color: white; text-align: center; text-transform: uppercase; font: inherit; }

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. Change the color of the first button’s shadow to rgba(39, 174, 96, 0.5).
    2. Change the color of the second button’s shadow to rgba(231, 76, 60, 0.5).

    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.