+ Start a Discussion

Issue setting font color in Visualforce page using stylesheets

I am trying to set properties on a column using a stylesheet instead of embedded style values. However I cannot get the stylesheet method to work when applying color to the text. I am fairly new to VF and this is my first time trying to use a custom stylesheet.

Here is the component that renders correctly using style option: 
<apex:column value="{!i.Display_Value6__c}" style="background:#DAF6FF;color:red"/>

Here is the component using the stylesheet which correcly applies the background color but not the font color: 
<apex:stylesheet value="{!$Resource.InventoryStyleSheet}"/>
<apex:column value="{!i.Display_Value6__c}" styleClass="colorstyle_red"/>

here is the contents of the style sheet which I've uploaded as a static resource.
.colorstyle_red { 
background: #DAF6FF; 
color:red; }
Best Answer chosen by debra

Unfortunately your styleclass is getting overridden by the standard Salesforce css.  When I look at a cell from an table with an apex:column, I see the color is set by a rule like this in the Salesforce css:
body .pbBody table.list tr th, body .pbBody table.list tr td

So this will set it, but you'll want to narrow it down a bit rather than use all this:
body .pbBody table.list tr th, body .pbBody table.list tr td.colorstyle_red { 
  background:  #DAF6FF; 

I tend to either use standard components and make it look exactly like standard Salesforce, or create my own to avoid conflicts like this.

Robert K - OpFocus