Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Problem with my linear-gradient

Hi, this is my background for the header element:

background: url("img/showcase-background.jpg") no-repeat center center/cover;

I want to put linear gradient over it that will come from the top and end after 20% of the element's height. What should be the second value (instead of that pink color) for gradient to end? Also this code does not work, why? :

background: linear-gradient(black, pink 20%), url("img/showcase-background.jpg") no-repeat center center/cover;

1 Answer

Steven Parker
Steven Parker
216,017 Points

To make it start black and fade out, then instead of "pink" use "transparent".

And the code seems OK, so perhaps there's an issue with the code near it. Post the whole code here if you'd like us to check it.

Here is the whole code from the CSS file about header element:

header {
  min-height: 75vh;
  background: url("img/showcase-background.jpg") no-repeat center center/cover;
  box-shadow: inset 0px 0px 300px 170px rgba(0,0,0,0.75);
  position: relative;

When it is like this it is working, only when I put this linear-gradient before the url everything crash

Oh, okay, evertyhing is working now, thank you a lot for help :)