HTML Academy
Color Transitions in px
Linear Gradients13/23
Back to the list of tasks
  • 1. Hello, linear-gradient!
  • 2. Gradient Direction
  • 3. Diagonal Gradients
  • 4. Gradients at an Angle
  • 5. Diagonals vs. Degrees
  • 6. Challenge: Application Icons
  • 7. Uniform Multicolor Gradient
  • 8. Color Proportions and Color Stops
  • 9. Sharp Color Transitions
  • 10. Pseudo-Columns on Gradients
  • 11. Challenge: Flags
  • 12. Color Transitions in px
  • 13. Semi-Transparent Gradients
  • 14. Repeating Linear Gradient
  • 15. Creating a Complex Background – Part 1
  • 16. Creating a Complex Background – Part 2
  • 17. Creating a Complex Background – Part 3
  • 18. Let’s Create a Complex Background – Final Step
  • 19. Buttons – Part 1
  • 20. Buttons – Part 2
  • 21. Buttons – Part 3
  • 22. Challenge: Ornament Made of Shurikens
  • 23. Challenge: Satellites
Repeating Linear Gradient
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Semi-Transparent Gradients

In CSS, you can set any color to have semi-transparency, or even set a transparent color. This is done using the rgbacolor values that support transparency in addition to the three color components. Examples:

  • rgba(255, 255, 255, 1) — Regular white color.
  • rgba(255, 255, 255, 0.5) — 50% transparent white.
  • rgba(255, 255, 255, 0) — 100% transparent color.

You can also set a transparent color using the keyword transparent.

Transparent and semi-transparent colors are also used in gradients to create interesting effects.

In this task, you need to complete the image by writing striped semitransparent gradients of the two remaining squares by analogy with the two existing ones, so that you end up with another square in the center.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Semi-Transparent Gradients</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="squares"> <div class="square square-top-left"></div> <div class="square square-top-right"></div> <div class="square square-bottom-left"></div> <div class="square square-bottom-right"></div> </div> </body> </html>
CSS
.square-top-left { background-image: linear-gradient( 135deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75% ); } .square-top-right { /* Colors: white 30% opacity, transparent, white 30% opacity, transparent */ } .square-bottom-right { background-image: linear-gradient( 315deg, rgba(255, 255, 255, 0.4) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.4) 75%, transparent 75% ); } .square-bottom-left { /* Colors: white 50% opacity, transparent, white 50% opacity, transparent */ } .squares { margin: 70px auto; width: 300px; height: 300px; background-color: #3498db; } .square { float: left; width: 50%; height: 150px; } html, body { margin: 0; padding: 0; }

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

    Add two gradients to the empty corner squares:

    1. Assign a gradient at an angle of 225° to the top right square.
    2. Assign a gradient at an angle of 45° to the bottom left square.
    3. Then change the background color of the .squares block to #8e44ad.

    The dimensions of the transitions are the same as the ones used for the first two squares. The colors are specified in the CSS code.

    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.