How to set a specific rich text button width using custom CSS

How to set a specific rich text button width using custom CSS

sunandmindco
Visitor
1 0 1

Hi!

I am trying to set my button width to a consistent value regardless of the text length. Right now, my buttons are changing size dependent on text length, which is fine for most pages of my website, but I want to create a quick links page where all buttons are set to the same size.

 

Right now, I have all of the buttons in different rich text sections where I have been trying to edit the custom CSS, but changing width alters the alignment of the entire button section to the right.

 

I attached an image showing the ideal button width alignment and an image showing what it looks like now. Does anyone know how I can accomplish this without adding longer text (such as the dots to fill the space)?

 

Screenshot 2025-03-22 at 9.41.12 AM.pngScreenshot 2025-03-22 at 9.07.13 AM.png

Thank you!

Reply 1 (1)

paulrainstorm
Shopify Partner
19 0 3

Hi @sunandmindco 

You can wrap all <button> tags in a parent <div class="parent"> tag and add the below CSS

div.parent {
width: 300px;
}

div.parent > button {
display: block;
width: 100%;
}

Found my reply helpful? Click Like to let me know!
Got your question answered? Mark it as an Accepted Solution.
Interested in working together? Contact Us Now!