I am trying to write some code to create a gradient background using javascript. I have looked at the FAQ section, but I am new to javascript and the solution in there is too complicated for me (it also seems that there must be a simpler method).
I have a good script, but I now have 2 small probs:
1. how can I reduce the height of the divs I create to less than 20px ("newDiv.style.height = 10px" does not work) ?
2. how can I control the CSS float property in order to allow my script to achieve horizontal as well as vertical gradients ?
I have a good script, but I now have 2 small probs:
1. how can I reduce the height of the divs I create to less than 20px ("newDiv.style.height = 10px" does not work) ?
2. how can I control the CSS float property in order to allow my script to achieve horizontal as well as vertical gradients ?
Code:
<!--
var i = 0;
var j = 0;
for (j = 0; j < 25; j++)
{
var newDiv = document.createElement("div");
newDiv.style.width = 100;
newDiv.style.height = 20;
document.getElementsByTagName("body")[0].appendChild(newDiv);
for (i = 0; i < document.getElementsByTagName("div").length; i++)
{
document.getElementsByTagName("div")[i].style.backgroundColor = (256*256*i*10) + (256*i*10) + i*10;
}
}