Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-09-2012, 08:47 PM   PM User | #1
SteveH
Regular Coder

 
Join Date: Nov 2005
Posts: 615
Thanks: 91
Thanked 1 Time in 1 Post
SteveH is an unknown quantity at this point
CSS gradient browser question

Hello

I have created a gradient for a table background colour using the link here:

http://ie.microsoft.com/testdrive/gr...r/default.html

I then placed the code it that the site generates into an external style sheet, and in my HTML page I have this:

Code:
<table class="center" border="0" cellspacing="0" cellpadding="0">

<tr><td width="100%" align="center" valign="top"><div id="gradient">

TEXT

</div>
</td></tr></table>
I can see the gradient in page using Safari, but not in my default browser, IE9. Why is that, please? This is what I have for gradient in my style sheet:

Code:
#gradient {

height: 100%;

padding: 10px;

/* Note: This gradient may render differently in browsers that don't support the unprefixed gradient syntax */

/* IE10 Consumer Preview */ 
background-image: -ms-linear-gradient(top left, #28AB66 0%, #73CC9D 100%);

/* Mozilla Firefox */ 
background-image: -moz-linear-gradient(top left, #28AB66 0%, #73CC9D 100%);

/* Opera */ 
background-image: -o-linear-gradient(top left, #28AB66 0%, #73CC9D 100%);

/* Webkit (Safari/Chrome 10) */ 
background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0, #28AB66), color-stop(1, #73CC9D));

/* Webkit (Chrome 11+) */ 
background-image: -webkit-linear-gradient(top left, #28AB66 0%, #73CC9D 100%);

/* W3C Markup, IE10 Release Preview */ 
background-image: linear-gradient(to bottom right, #28AB66 0%, #73CC9D 100%);

}
Many thanks.

Steve
SteveH is offline   Reply With Quote
Old 12-18-2012, 11:10 PM   PM User | #2
dstorey
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
dstorey is an unknown quantity at this point
The code is correct. The problem is that IE only started supporting gradients in IE10. IE9 and below do not support it, so will only display the fallback (if any). Usually a gradient isn't something that is critical for the site to work correctly, so just adding a solid color fallback may be ok. e.g. add something like:

background-color: #28AB66; (or pick a midpoint between your two colours) before your gradient properties.

You can also remove the -ms-linear-gradient rule, as the final version of IE10 was released without prefix. That is only needed for users of IE10 platform preview on Win8, which is likely only going to be a very limited number of developers.
dstorey is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:53 AM.


Advertisement
Log in to turn off these ads.