You need to sign in to do that
Don't have an account?
Ratheven Sivarajah
How do you write css on a visual force-Page.
Hey I am new to visualforce. I am coding through VScode. I am able to get the particular data and show it on my sandbox and It looks fine when I put lightningStyleSheet="true". When I put the page in a site the css changes. Is this because there is a wrapper over my page that is influencing the css. If so how would I find out? Is there a way to overpower that css? How do you write css in a apex page, do you create a different style page and connect? A lot of question I know, Thanks for the help.
This is the code:
<apex:page controller="TestQuote" lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Quote Request Name:" for="name" ></apex:outputLabel>
<apex:outputField value="{!result.Quote_Request__r.name}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
This is the code:
<apex:page controller="TestQuote" lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Quote Request Name:" for="name" ></apex:outputLabel>
<apex:outputField value="{!result.Quote_Request__r.name}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Inline CSS: You can use the style attribute within HTML tags to apply CSS styles directly. For example:
<apex:outputLabel value="Quote Request Name:" for="name" style="font-size: 14px; color: #333;"></apex:outputLabel>
External CSS file: You can create a separate .css file and link it to your Visualforce page using the <apex:stylesheet> tag. For example:
<apex:stylesheet value="{!URLFOR($Resource.MyCSS, 'MyCSS.css')}" />
Apex CSS classes: You can define CSS styles in your Apex class using the <style> tag. For example:
<style type="text/css"> .quote-request-label { font-size: 14px; color: #333; } </style>
And then apply the class to your label using the styleClass attribute:
<apex:outputLabel value="Quote Request Name:" for="name" styleClass="quote-request-label"></apex:outputLabel>
To determine if the site wrapper is influencing the CSS, you can inspect the elements using the browser's developer tools to see what styles are being applied to your elements and from where. To overpower the site wrapper's CSS, you can add higher specificity to your own styles, or use !important to force your styles to take priority.
Below is an example for your code
All Answers
Inline CSS: You can use the style attribute within HTML tags to apply CSS styles directly. For example:
<apex:outputLabel value="Quote Request Name:" for="name" style="font-size: 14px; color: #333;"></apex:outputLabel>
External CSS file: You can create a separate .css file and link it to your Visualforce page using the <apex:stylesheet> tag. For example:
<apex:stylesheet value="{!URLFOR($Resource.MyCSS, 'MyCSS.css')}" />
Apex CSS classes: You can define CSS styles in your Apex class using the <style> tag. For example:
<style type="text/css"> .quote-request-label { font-size: 14px; color: #333; } </style>
And then apply the class to your label using the styleClass attribute:
<apex:outputLabel value="Quote Request Name:" for="name" styleClass="quote-request-label"></apex:outputLabel>
To determine if the site wrapper is influencing the CSS, you can inspect the elements using the browser's developer tools to see what styles are being applied to your elements and from where. To overpower the site wrapper's CSS, you can add higher specificity to your own styles, or use !important to force your styles to take priority.
Below is an example for your code
Shri Raj and Roberto Mitchel I really appreciate it.