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.

CSS

Joe Consterdine
Joe Consterdine
13,965 Points

Can't get overlay above image?

Hey guys,

I need to add an overlay when I have over my image.

I need to do this WITHOUT a background-image. I know it's easier to do it that way but I need to be able to do it with a regular image tag.

Why in this example does Z-index not work?

And if something could get a working example of when you hover over the image the image opacity lowers with the text remaining visible on top so you can see it clearly!

Much appreciated guys!

Joe

Jesus Mendoza
Jesus Mendoza
23,274 Points

Hey Joe I made this pen long time ago and I think it might help you http://codepen.io/Jesusz0r/pen/ZGzBLO

2 Answers

Joe Consterdine
Joe Consterdine
13,965 Points

Hi Jesus,

that's awesome! Is CSS3 the only way to do it?

Btw, how long you been coding? I think you helped me out last time so thanks a lot!

Jesus Mendoza
Jesus Mendoza
23,274 Points

Do you want to do it with jQuery? I've been coding for almost a year now but I always get distracted so I forget things and gotta learn them again xD

Joe Consterdine
Joe Consterdine
13,965 Points

Only a year? That's impressive man.

I've been learning about 14 months now so you must be learning a lot because I spend everyday on here!

And no...css is fine haha :)