I created a grid on a template. The grid will usually have 4 buttons, but sometimes it will have less. What I want is the grid to be horizontally centered to the rest of the template no matter how many buttons there are. Can this be done somehow?
Thanks!
Waqar, thank you very much for the detailed reply!
Unfortunately this doesn't give the result I want to have. Let me explain:
What I want to have is 1 to 4 buttons next to each other, like the coloured ones in this screenshot (hidden link). The result I got following your help is the grey ones at the top.
In this screenshot (hidden link) I have disabled one of the buttons, so only three remain active. I need those three (or two or one in other cases) to stay horizontally centered no matter what.
Also, I want to remove that "No Items Found" at the bottom. I really don't know where it came from.
It is now clear that those buttons are coming from multiple custom fields of the same post. The solution I shared earlier was for a case when buttons were needed from multiple posts, through a view.
In your content template "Template for Fonts", you don't need a view so you can remove that entire block.
As for the colored buttons in a "Grid" block, you can remove the grid block and its containing buttons and instead add a "Container" block and assign it the ID "centered-buttons-container".
( example screenshot: hidden link )
Next, you can add the 4 "Button" blocks inside this container block directly.
( example screenshot: hidden link )
The last step would be to include some custom CSS code in the template to make sure that the buttons inside this particular container are always centered:
Your detailed help actually solved my problem, I just have an additional question.
Is there an easy way to bring them all a little closer together towards the vertical center? In other words, I want to decrease the distance between them.
Note: Feel free to adjust the "80%" value to increase or decrease the spacing between the buttons.
And to check the CSS code that is applying to different page elements, you can use Google Chrome's inspect element tool, as explained in this guide: hidden link