+ Start a Discussion
VisualForceVisualForce 

Pageblock background color

Hi..
      How to change the pageblock background color... I am using pageblocktable so that only I am using pageblock here.. I can change the pageblocktable color using bgcolor attribute...
      I want a white background .. How is it possible in pageblock
Best Answer chosen by Admin (Salesforce Developers) 
mtbclimbermtbclimber
While this works today be advised that this component's style is meant to be managed by salesforce and the structure/style classes you see today are not guaranteed to be stable.   The best advice is to create your own pageblock component with the style attributes you want and css class names which refer to styles in your static resource stylesheet (not the salesforce.com standard CSS). 

Of course there is always a judgement call as to how significant an impact a change would cause. In this case if the background color goes from white to the default then it might not be too bad to take a reactive approach... unless, perhaps, if you are using a font color that is equal to our background color ;-)

All Answers

hisrinuhisrinu
Hi,

 As per my knowledge you can't change the background of the pageblock, because it uses the salesforce standard style sheets.
 If you want to change the background, you should not place the code in pageblocks, you have to remove it and then apply your custom style sheets.

harlequinharlequin

You can override the stylesheets by using a styleblock at the top of your page

Code:
<apex:page>
    <style type="text/css">
/* Color for the title bar */ .bPageBlock .pbHeader { background-color:#FF0000; } .bPageBlock .pbBody {
/* Color for the pageblock background */ background-color:#FFFFFF; }
.bPageBlock
        {
/* Custom background image at the bottom of the pageblock
which you may need to edit.     
background-image:url(your_new_background_image);*/
        }

    </style>
    <apex:pageBlock title="Color Test" >
    <br /><br /><br /><br /><br /><br />
    </apex:pageBlock>
  </apex:page>

However, be aware that there is a background image at the bottom of the page block, which you'll need to update to get the colors correct. Although if you want a white background, you might not notice it, but there again ....


 



Message Edited by harlequin on 11-28-2008 04:40 AM
mtbclimbermtbclimber
While this works today be advised that this component's style is meant to be managed by salesforce and the structure/style classes you see today are not guaranteed to be stable.   The best advice is to create your own pageblock component with the style attributes you want and css class names which refer to styles in your static resource stylesheet (not the salesforce.com standard CSS). 

Of course there is always a judgement call as to how significant an impact a change would cause. In this case if the background color goes from white to the default then it might not be too bad to take a reactive approach... unless, perhaps, if you are using a font color that is equal to our background color ;-)
This was selected as the best answer
VisualForceVisualForce

    I have store the following code as priintcss in static resource, and I have already stored logo in static resource named logo.

Code:
@page {
 
 @top-right {
  content: "Page " counter(page);
 }
                   @top-left{
                                   background-image: url('logo');                               
                  }              
}


 

I am using following code in VF page..

<apex:page controller="HistoryCon" showHeader="false" renderAs="pdf">
 <apex:stylesheet value="{!$Resource.printcss}"/>

          I want to render a PDF file.. I can get a page number in each page but I couldnt get a image...

Where I made a mistake... Give me a solution..

        Next problem is

            How to add a merge field value in header or footer.. That is I need Account name in each page of PDF..

If it is not possible in Visual force give any other alternate solution...