0

I have a Static Resource (Hardcoded URL) and a VF page for that. I want to get rid of the hard coded values and refer the static resource in my VF page. In order to do that i created a zip file of static resource with CSS and Image.Please let me know how can i refer and what changes to be done to the CSS file.

Part of the code:

Page:

<apex:page StandardController="KB__kav" extensions="ArticleExtension" showHeader="false" sidebar="false" standardStylesheets="true" title="{!KB__kav.Title}">

<head>
    <style> div.pbSubheader
        {
        font-size:20px; 
        background-color:blue !important;
        border-color: none !important
        } 
    </style>
</head>

<body class="hasMotif knowledgeTab">

<knowledge:articleRendererToolBar canVote="true" articleId="{!$CurrentPage.parameters.id}" rendered="true"/>

<apex:stylesheet value="{!$Resource.kb_css}" />
      <p>
     <apex:outputField value="{!KB__kav.Document__c}"/>
     </p>

</body>
</apex:page>


CSS:

div.content2015 h1{
    color : #003366;
    margin: 0px 5px 8px 0px;
    padding-left: 5px;
    padding-right: 170px;
    padding-bottom: 15px;
    padding-top: 0px;
    background-image: url("https://c.cs3.content.force.com/servlet/servlet.FileDownload?file=015Q0000000Ob8d");
    background-repeat: no-repeat;
    background-position: 100% 0%;
    font-size: 22px;
    font-weight: bold;
    font: arial, sans-serif;

}

Thanks!

1

As @crmprogdev says, you will probably find the official Salesforce resources helpful. In this specific case, you should put both the CSS and image into a static resource like so:

/MyStaticResource
  /css
    /style.css
    /example.css
  /img
    /content2015.png
    /example.png

You then change your CSS to refer to the image with a relative URL:

background-image: url("../img/content2015.png");
0

Welcome to SFSE sha. I recommend the following resources Visualforce Workbook, the Visualforce Developer’s Guide where the answers to your very basic questions are clearly explained and well documented. I also highly recommend you visit Trailhead and go through the Visualforce Module where I think you'll learn a great deal on how to do create Visualforce pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.