You need to sign in to do that
Don't have an account?
How to change the outputpanel width and center the contents of the pageblock?
I have a VF page with a number of questions in the outputLabel and they are wrapping. Also, my page is heavily weighted to the left and I'd like to find a way to center up the content. Is there a way to control the width of the output labels and also to get better centering on the page?
<apex:pageBlockSectionItem>
<apex:outputLabel value="Have you been engaged with this client before?" for="q2"/>
<apex:outputPanel>
<apex:selectList id="q2" value="{!q2}" size="1">
<apex:selectOption itemValue="yes" itemLabel="Yes"/>
<apex:selectOption itemValue="no" itemLabel="No"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
TIA, Mark
You can use the style attribute to specify width and centering, though this does not work in all cases...
Example
<apex:outputLabel style="font-weight:bold;" value="Contact E-mail" > <div style="position:relative;left:75px;"> <apex:commandButton value="Search" action="{!contactsearch}" /> </div>
All Answers
You can use the style attribute to specify width and centering, though this does not work in all cases...
Example
<apex:outputLabel style="font-weight:bold;" value="Contact E-mail" > <div style="position:relative;left:75px;"> <apex:commandButton value="Search" action="{!contactsearch}" /> </div>
You can also prevent wrapping of text in the label using css like so:
<apex:outputLabel value="Have you been engaged with this client before?" for="q2" style="white-space:nowrap;"/>
If you want to specify the width of an outputPanel, you need to set the layout attribute to "block". By default, outputPanel renders as <span> tag, which would ignore the width CSS attribute.
Below is an example of outputPanel from the Visualforce Dev Guide.
Span Example <!-- Spans do not add any additional formatting to the body of the outputPanel. --> <apex:outputPanel id="thePanel">My span</apex:outputPanel> The example above renders the following HTML: <span id="thePanel">My span</span> Div Example <!-- Divs place the body of the outputPanel within the equivalent of an HTML paragraph tag. --> <apex:outputPanel id="thePanel" layout="block">My div</apex:outputPanel> The example above renders the following HTML: <div id="thePanel">My div</div>