Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Keith Short
5,971 PointsCan you make a gradient fade into transparency?
I have the following code for making an image at the top of the page fade into another color:
background: linear-gradient(0deg, #F3FAB6, transparent), #444 url('../img/main_badger.jpg') no-repeat center;
I also have a repeating background image which covers my entire <html> web page, is there any way to make an image fade into the web page's background, instead of a simple color?
Thanks in advance!
1 Answer
Greg Kaleka
39,021 PointsSure! The gradient you defined above works fine for me.
Here's a codepen using your rule:
http://codepen.io/anon/pen/rVJKax?editors=110
Edit: Ah! I see. Unfortunately, there's not a good way to do this, but we can hack it: You can do this using masks, but not with a background property. Instead, we stick an image in the html, set position: absolute, and use z-index to move it behind your content.
New codepen:
Keith Short
5,971 PointsKeith Short
5,971 PointsSorry I think I'm just wording my question badly.
That code works fine but say I am trying to make the gradent turn the image itself see through. So that I can see the repeating background image through the object.
Here is a codepen for example:
http://codepen.io/anon/pen/WvMLgY?editors=110
The gradient fades out but you can clearly see where the div object stops and the repeating background starts. I am trying to make the gradient fade out so that you can see the background behind it.
Thanks
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsHey Keith - I updated my answer above.