views:

45

answers:

2

hi,

I need to display text on a blue gradient color background within a table. How could I render this using Javascript?

Thanks a lot!

A: 

The best way to do this is by css and background image with gradient. use background css property.

Lukasz Dziedzia
+1  A: 

You can do this with CSS if you know that your visitors browsers support this feature: http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/

Another link worth visiting is this page that has a CSS generator that allows you to create the style interactively: http://gradients.glrzad.com/

Here's the CSS for a blue gradient:

-webkit-gradient(
    linear,
    left bottom,
    left top,
    color-stop(0.18, rgb(20,169,250)),
    color-stop(0.67, rgb(43,61,255)),
    color-stop(0.86, rgb(36,54,171))
)
-moz-linear-gradient(
    center bottom,
    rgb(20,169,250) 18%,
    rgb(43,61,255) 67%,
    rgb(36,54,171) 86%
)
Bernhard Hofmann
hello,I have another question. My current code is like this which I apply a static color such as document.getElementById("box1").style.backgroundColor = "#ffff00";. How do I apply this -webkit-gradient() style into this function?function clickedElement(){document.getElementById("box1").style.backgroundColor = "#ffff00";}Thanks so much for your help.
Java Doe
Hey Java Doe - You seem to be missing a few acceptances. You've asked 12 questions on Stack Overflow and none have an accepted answer. You will find you get MUCH more help from people if your accept rate was more than 0%. You should click the tick on the left of the answer you accept for your questions. Your questions are listed in your profile.
Bernhard Hofmann
To your question, the style should be defined in a CSS class, say "banner", and then you'll be able to add that class to the elements you want by using document.getElementById("box1").className += " banner"; See this question: http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript
Bernhard Hofmann
Hi,Thanks so much for the info.I did not realize the check mark on the left of the answer is clickable.I just accepted the answer.
Java Doe
Excellent work - not the accepting this answer, but the others. Glad to see your accept rate is now much higher.
Bernhard Hofmann