function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nicholas MiramsNicholas Mirams 

How do I center the top command button?

Hi,
I am new to visualforce and trying to create a list view of opportunities for the mobile app,  Here is the page so far: -

User-added image
How on earth do I move the commant button tot he middle?  The botom one is centered but not the tope one; 

code: -
<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" sidebar="true" lightningStylesheets="true">
    <apex:form >        
          <apex:pageblock >       
              <apex:pageBlockSection title="MY OPPORTUNITIES" columns="2" collapsible="false"> 
                          <apex:selectList value="{!filterId}" size="1">
                                <apex:actionSupport event="onchange" rerender="opp_table"/>
                                <apex:selectOptions value="{!listviewoptions}"/>
                          </apex:selectList>
                      <div>
                         <left><img src="{!$Resource.OpportunityLogo}" height="50" width="50"/></left>
                      </div>    
             </apex:pageBlockSection> 
                   <apex:pageBlockButtons location="both">
                    <apex:commandButton value="Save" action="{!save}" style="float:center;color: #1798c1; font-size: 17px;font-weight: normal; border-radius:0;" />
                </apex:pageBlockButtons>
               
                 
            <apex:pageBlockTable value="{!opportunities}" var="opp" id="opp_table">
                <apex:column value="{!opp.name}" title="Opportuntiy Name"/>
                <apex:column value="{!opp.Account.Name}"/>
                <apex:column value="{!opp.CTN_Service__c}"/>
                <apex:column headerValue="Stage">
                    <apex:inputField value="{!opp.stageName}"/>
                </apex:column>
                <apex:column headerValue="Close Date">
                    <apex:inputField value="{!opp.closeDate}"/>
                </apex:column>
                <apex:column headerValue="Amount">
                    <apex:inputField value="{!opp.amount}"/>
                </apex:column>
             </apex:pageBlockTable>   
        </apex:pageBlock>
    </apex:form>
</apex:page>

Any ideas how or a better way to show a related opportunity list on salesforce?
Thanks!​​​​​​​
Khan AnasKhan Anas (Salesforce Developers) 
Hi Nicholas,

Greetings to you!

Please try below code, it should work.
 
<div align="center" draggable="false" >
    <apex:commandButton value="Save" action="{!save}"/>
</div>

Or you can use <apex:pageBlockButtons> in the pageblock layout.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Nicholas MiramsNicholas Mirams
Thanks for this,

I now have one centered and the other slightly to the right..

<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" sidebar="true" lightningStylesheets="true">
    <apex:form >        
          <apex:pageblock >   
                   <apex:pageBlockButtons location="both">
                   <div align="center" draggable="false" >
                        <apex:commandButton value="Save" action="{!save}"/>
                   </div>
                    </apex:pageBlockButtons>  
                              <apex:pageBlockSection title="MY OPPORTUNITIES" columns="2" collapsible="false"> 
                                  <apex:selectList value="{!filterId}" size="1">
                                        <apex:actionSupport event="onchange" rerender="opp_table"/>
                                        <apex:selectOptions value="{!listviewoptions}"/>
                                  </apex:selectList>
                                  <div>
                                     <left><img src="{!$Resource.OpportunityLogo}" height="50" width="50"/></left>
                                  </div>             
                              </apex:pageBlockSection>
                     <apex:pageBlockTable value="{!opportunities}" var="opp" id="opp_table">
                      <apex:column value="{!opp.name}" title="Opportuntiy Name"/>
                      <apex:column value="{!opp.Account.Name}"/>
                      <apex:column value="{!opp.CTN_Service__c}"/>             
                      <apex:column headerValue="Stage">
                      <apex:inputField value="{!opp.stageName}"/>
                    </apex:column>
                      <apex:column headerValue="Close Date">             
                      <apex:inputField value="{!opp.closeDate}"/>
                    </apex:column>
                      <apex:column headerValue="Amount">
                      <apex:inputField value="{!opp.amount}"/>              
                    </apex:column>
             </apex:pageBlockTable>   
        </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image