Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1307

How to make a flexbox container auto-width and centered with buttons aligned next to each other?

$
0
0

Im using the following code, but the container is still full width

I'd like it to adapt to the width of its contents

.cta-primary {    display: flex;    justify-content: center;    align-items: center;    width: auto; /* Container width is determined by its contents */    margin: 0 auto; /* Centers the container within its parent */}.cta-primary .button-group {    display: flex;    gap: 10px; /* Optional spacing between buttons */}<div class="cta-primary"><div class="button-group"><a href="contact" class="btn btn-primary">One</a><a href="contact" class="btn btn-primary">Two</a></div></div>

I tried width: auto but it makes no difference


Viewing all articles
Browse latest Browse all 1307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>