¡De Colores!
Feb 16, 2000 -
©
I know this might not happen very often, but, suppose you wanted the viewers of your website to be able to choose the colours used in different elements of your pages. How would you go about doing it? What if you wanted to change the background colour of your web page when the viewer performs a certain action (such as a click or a mouse-over), revealing some hidden text? It's not hard to do. Lemme show you. First of all, you have to be familiar with cascading stylesheets, or CSS. (If you just said, "Huh?", go see my article on it.) Secondly, you might want to know a smidgen of JavaScript, but it's not absolutely necessary. You can read my article on JavaScript image swapping or get a quick overview from the good folks at Webmonkey. In particular, you'll want to know how JavaScript functions work, but I'll try to explain as best as possible. For our trial run, just make a generic web page with a good bit of text. I used the lyrics to one of my favourite songs. Set it up with some default styles, like so:
Next, you'll want to define some JavaScript functions that tell the browser to change the colour. Insert this somewhere in the
Alright, we've got these functions defined. What exactly are we supposed to do with them? For starters, when you use them in your web page, you have to plug in a colour for "espalda" or "texto", like:
Then, you have to tell the browser to change the colours upon certain events:
And that's it! I know I kinda whirlwinded thru it, but if you look at this page and its code, you'll get a better feel for how to implement what you've learned in your own web site. Some tips on implementation: make sure you type the function name EXACTLY how you typed it in the
The copyright of the article ¡De Colores! in Web Graphic Design is owned by . Permission to republish ¡De Colores! in print or online must be granted by the author in writing.
Go To Page: 1 2 Articles in this Topic Discussions in this Topic |