HTML Academy
Gradients at an Angle
Linear Gradients5/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
Challenge: Application Icons
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Diagonals vs. Degrees

Sometimes gradients whose directions are specified using degrees and diagonals look the same.

to right top
45deg

However, these behaviors work differently. Gradients that are specified using degrees are assigned independently of the shape of the container, whereas diagonal gradients are dependent on the latter. Diagonal gradients always remain anchored to their corners.

Of course, if the containers are square, then there will be no difference. But what happens if you stretch them in height? Let’s check.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Diagonals vs. Degrees</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="content"> <div class="gradient gradient-diagonal"></div> <div class="gradient gradient-degrees"></div> </div> </body> </html>
CSS
html, body { margin: 0; } .content { margin: auto; margin-top: 150px; width: 350px; } .gradient { width: 150px; height: 150px; box-shadow: 0 0 3px #333333; } .gradient-diagonal { float: left; background-image: linear-gradient(green, yellow, green); } .gradient-degrees { float: right; background-image: linear-gradient(green, yellow, green); }

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. Set the direction of the .gradient-diagonal block gradient from
      bottom left to the top right corner.
    2. Assign a direction at an angle of 45° to the .gradient-degrees block gradient.
    3. Then increase the height of both blocks to 300px.

    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.