How to align a button? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to align a button?

I’ve made a button in css, but it doesn’t align to the center even though it has a text-align:center; Css: .SignUp{ Text-align:center; Border-radius:5px; Background-color:green; Padding:10px; Border:1px solid pink; Width:50px; } The button works, I just can’t align it to the center. Can anyone help?

2nd Jun 2019, 1:27 AM
Добежал фуопйль ярлычок
Добежал фуопйль ярлычок - avatar
3 Answers
+ 3
Parent element is the higher level element of the children elements Check this out https://code.sololearn.com/WLsqz8x30Z08/?ref=app Take note: all css codes must be in lowercase form. you could add character "-" for class/id name for better readability, but not uppercase letter. css selector and property are strictly in lower case letters.
2nd Jun 2019, 3:31 AM
Calviղ
Calviղ - avatar
+ 1
Добежал фуопйль ярлычок your css already aligned the text of the button to center, relative to the button itself. If you want to align the button to center, you need to set text-align center from the parent of the button element. The parent element must be block element with width to full width.
2nd Jun 2019, 2:13 AM
Calviղ
Calviղ - avatar
0
Calviղ whats the parent element?
2nd Jun 2019, 2:24 AM
Добежал фуопйль ярлычок
Добежал фуопйль ярлычок - avatar