+ 2
Centering text in the middle of a box
I am pretty new to any coding, just having fun learning at this point. I am trying to figure out how to center text vertically and horizontally within a box using CSS, but I’m not sure how. I used text-align: center, but that just centered it in the browser window. I have a box around my heading and I want the text to be centered in the box. Can anyone help with that?
4 Antworten
+ 1
or...try this
https://code.sololearn.com/WFH6dDX785WG/?ref=app
+ 3
If this helps.
Also there would be many other ways to center it.
https://code.sololearn.com/W87twWcbZphL/?ref=app
+ 1
Add a class to that text,
.className{
margin-left:auto;
marign-right: auto;
}
It will comes the text center.