Trying to center button on the page

983    Asked by ankur_3579 in Salesforce , Asked on Jul 19, 2021

I have the following component code that I am trying to use to center a button on a page. It keeps showing left-aligned. I have tried using

tag and slds-align_absolute-center. Neither change the left alignment I am seeing.

How to center button in div?

Answered by ankur Dwivedi

In order to align a button in the center. you need to use the Absolute Center class in slds positioned.


For more information: https://www.lightningdesignsystem.com/utilities/alignment/

Here is How you can align lightning-button in Salesforce LWC?

Sample Code:

HTML:


 

     

         

     

 

 

     

         

     

 

 

     

         

     

 


Output:

Hope this will help you.



Your Answer

Interviews

Parent Categories