English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i've been looking for some help regarding CSS. all i want to do is have the CSS change a certain word into an image.

for example, if the word "red" appears on a page, i would like that to change into a small image.

can this be done, or am i thinking of the wrong programming language

2007-07-16 02:17:31 · 6 answers · asked by Recycled Paper 1 in Computers & Internet Programming & Design

6 answers

CSS no. Javascript yes:



This replaces every instance of "red" in the entire HTML body with an image


You can use other tags if you know where red is likely to show up.

2007-07-16 02:49:04 · answer #1 · answered by E.M.Bed 5 · 0 0

Like the other two answers, CSS is not the language to accomplish this. With Javascript and CSS you can accomplish this. First you must create a function in JS that will grab all the elements with the css class name.

document.getElementsByClass = function( clsName ){
var retVal = new Array();
var elements = document.getElementsByTagName( "*" );
for(var i = 0;i < elements.length;i++){
if(elements[i].className.indexOf(" ") >= 0){
var classes = elements[i].className.split( " " );
for(var j = 0;j < classes.length;j++){
if(classes[j] == clsName)
retVal.push(elements[i]);
}
}
else if(elements[i].className == clsName)
retVal.push(elements[i]);
}
return retVal;
}

Then identify all your elements with a specific class name:
Red

Then run this function that will loop and replace all the class="red" elements with your image on the page load:

2007-07-16 02:57:32 · answer #2 · answered by Anonymous · 0 0

This is not for CSS, but rather a server-side scripting language (PHP, Perl, ASP.NET...). Though maybe JavaScript too. CSS can only be use to specify styles for HTML tags.

2007-07-16 02:29:13 · answer #3 · answered by Vera 5 · 0 0

This red



Then in


...will provide something similar - adjust left, height, padding, width as needed

2007-07-16 04:10:14 · answer #4 · answered by fjpoblam 7 · 0 0

u'r a dressmaker and u do not understand this 8H!T? the place did u learn how to layout? attempt this:

answer #5 · answered by cosner 4 · 0 0

no its not possible with css... im sorry
try using some powerful stuff like jsp, asp etc

2007-07-16 02:34:38 · answer #6 · answered by karthik 3 · 0 0

fedest.com, questions and answers