ani168 Posted October 11 Posted October 11 How can I align the button to the center within the selector? This button was coded with simple HTML and CSS, and for some reason it's aligned to the left. HTML: <a href="#" class="btt"> Back to Top </a> CSS: .btt { color: white; font-weight: bold; text-align: center; display: inline-block; background: black; padding: 8px 24px; border-radius: 100px; } .btt:hover { background-color: #FF8282; }
Spark-Plugin Posted October 11 Posted October 11 (edited) Hi @ani168, Please give this updated code a try and let me know how it works for you: <div class="button-container"> <a href="#" class="btt"> Back to Top </a> </div> <style> .btt { color: white; font-weight: bold; text-align: center; display: inline-block; background: black; padding: 8px 24px; border-radius: 100px; width: fit-content; } .btt:hover { background-color: #FF8282; } .button-container { display: flex; justify-content: center; /* Horizontally center the button */ align-items: center; /* Vertically center the button */ } </style> Edited October 11 by Spark-Plugin - Answered by Iuno from sparkplugin.com
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment