+ 2

Horizontal-align of text doesn't work:(

Can someone introduce how to align text in div to the center? https://code.sololearn.com/WJfSkb5aqPMY/?ref=app

10th Mar 2018, 8:59 AM
Amadeus
Amadeus - avatar
7 Réponses
+ 4
Hey look this website there's the solution here http://howtocenterincss.com/#contentType=text&content.text.lines=1&horizontal=center&vertical=middle&browser.IE=11 I already posted it inside my code so you can now see the working version.
10th Mar 2018, 6:22 PM
Tim Thuma
Tim Thuma - avatar
+ 4
I thing the align attribute will work with a block element like div tags. It won’t work in inline element like span tags.
10th Mar 2018, 11:18 AM
Warith Vatanaplachaigoon
Warith Vatanaplachaigoon - avatar
+ 3
Add a special p tag for the text and change div's position to relative(also works without specifying the position) https://code.sololearn.com/W490tA9dowxb/?ref=app
10th Mar 2018, 10:05 AM
Tim Thuma
Tim Thuma - avatar
+ 2
Thanks! That helped me a lot:)
10th Mar 2018, 12:26 PM
Amadeus
Amadeus - avatar
+ 2
Well I don't know how to make it work then.
10th Mar 2018, 6:15 PM
Tim Thuma
Tim Thuma - avatar
+ 1
finally it works. Thank you very much 4ur help
10th Mar 2018, 6:33 PM
Amadeus
Amadeus - avatar
0
But i noticed now that the div isn't aligned as we defined in css(top: 50%) I want to use percents in aligning components in my project.
10th Mar 2018, 6:00 PM
Amadeus
Amadeus - avatar