I want to know how to centralise a text inside a box | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I want to know how to centralise a text inside a box

To have a text appearing at the middle of a box.

21st Nov 2020, 8:58 PM
Adebayo Arasi
Adebayo Arasi - avatar
6 Answers
+ 2
Finally my question is solved. Thank you KINGDX . God bless you.
23rd Nov 2020, 10:30 AM
Adebayo Arasi
Adebayo Arasi - avatar
+ 1
Use css text-align: center;
22nd Nov 2020, 5:36 AM
CHMD
CHMD - avatar
+ 1
Sent the explanation of my question here already... check my message upward...
22nd Nov 2020, 7:28 AM
Adebayo Arasi
Adebayo Arasi - avatar
+ 1
Ok so if I got it right, you want to center a text inside a container vertically and horizontally. Then the easiest way to achieve that is using flexbox. I made a code demonstrating that for you. Check the CSS section at the bottom (the three last rules inside .centerxy). https://code.sololearn.com/WcT1rfKThZKW/?ref=app
23rd Nov 2020, 10:28 AM
CHMD
CHMD - avatar
0
Thanks for your response, but I have tried that, I didn't get the desirable result. This is the desirable result I wanted, please check this screenshot.
22nd Nov 2020, 7:25 AM
Adebayo Arasi
Adebayo Arasi - avatar
0
Sorry I can't send screenshot. But I want the text to be at the middle of a box, there should be equal space up and down.
22nd Nov 2020, 7:26 AM
Adebayo Arasi
Adebayo Arasi - avatar