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

CSS

Layered background is white in IE9. Any fallbacks/workarounds?

I have a new landing page up here, and it looks great in modern browsers. However, in IE9, it doesn't just look bad; it's unusable. The background turns white, and because the text on the page is white, you can't see anything. Normally I wouldn't care that much about IE9 compatibility, but I'd like someone to at least see the content of the page.

I've pasted the relevant CSS below, and you're welcome to check out the full CSS file from the site if you like. Any help would be appreciated!

background.css
html, body {
    height: 100%;
    width: 100%;
    color: #FFF;

    background: linear-gradient(to top, rgba(50,50,80,.9), rgba(50,50,80,.9)),
                #666 url("/img/businterior.jpg") no-repeat center;

    text-shadow: 5px 5px 8px #222;
}

2 Answers

Hello Greg. How is it going? Ohhh, good old IE...

Well, to be honest, I never really pay attention to IE's older versions. I assume it's a good idea to provide a fallback, though sometimes it's just not worth the hustle. As far as I can see, the "only" major issue here is the linear-gradient.

Not 100% sure about the fallback, though as far as I know IE9 support filters instead of gradients. So try inserting the following snippet into your css :

/*Should work both for IE8 and IE9 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#1471da, endColorstr=#1C85FB)";

Hope that helps. Cheers Greg!

Sweet - thanks Ognjen, this worked!

You should be able to create a fallback by defining it prior to the background property, e.g.:

/* Fallback without linear-gradient */
background: rgba(50,50,80,.9)), #666 url("/img/businterior.jpg") no-repeat center;
/* Browser will override line above if it can parse this:  */
background: linear-gradient(to top, rgba(50,50,80,.9), rgba(50,50,80,.9)), #666 url("/img/businterior.jpg") no-repeat center;