After checking related answers, I haven't found what I am looking for. Apologies if this is a duplicate question.
This specific HTML code is used multiple times on a page, within a product box, and is displayed on a product category page.
<div class"all-buttons-container">
<div class="button1-container">
<a class="button1">text</a>
</div>
<div class="button2-container">
<a class="button2 **hidden**">text</a>
</div>
</div>
In this simplified HTML structure, there is a container with two sibling elements. - Each sibling contains an anchor element.
The button containers are always visible.
Sometimes, the
.button2
anchor also has the bootstrap class ofhidden
, hiding the anchor. This is controlled within each product box based on the need for a second button. I have no control over this aspect.If the
.button2
anchor has thehidden
class, I need to add somemargin-top
to thebutton1-container
in order to vertically center it.
I initially considered using pure style (flexbox) but it didn't achieve the desired result.
I am exploring the option of running a jQuery or pure JS script every time the page finishes loading to automatically add the necessary top margin to each instance of this HTML, if needed. While I prefer not to do this, it may be required if I cannot find a simpler solution.
Any suggestions or solutions would be greatly appreciated!
Thank you in advance!
Cheers, Wayjo