+ Start a Discussion

Style is not working for apex:Image

Hi All,


I want to set the different color for the image when a button click. I tried using style/styleclass ,but the img color is not changing.


<apex:image id="ImgId" url="/servlet/servlet.FileDownload?file=01590000000xTAS" style="Color:black;background-color:black;" width="250" height="150"/>


pls help me out..





I tried this in the visual force page it is working fine.

<apex:image id="ImgId" url="/servlet/servlet.FileDownload?file=01590000000Syqz" style="Color:black;background-color:white;" width="250" height="150"/>

 I think it might be the problem with browser .

Just clear the cache of the browser and try it.

Hope it will work.


Hi Anil,


In my developer edition I again tried with new page: actual color of image remains same,it doesnt change into red frm black.

I even cleared my cache and tried IE and firefox.


<apex:page >
<apex:image id="ImgId" url="/servlet/servlet.FileDownload?file=01590000000x59l" style="Color:Red;background-color:white;" width="250" height="150"/>



This is the image (loading spin) I downloaded frm google & added jpge into DOC folder----->



You can try this - 










color: red;



<apex:image ........................ id ="imgbg"/>



And may be one issue in you code, U changed backgroundcolor, It will not display till image is .png type. You must change the code, something like-




<td style="Color:black;background-color:black;">

<apex:image id="ImgId" url="/servlet/servlet.FileDownload?file=01590000000xTAS" width="250" height="150"/>







Change the color of td that will display in back. 


Please marked as solution, for other person help on a same query


Thank you,

Raj Jha