I have text on my html site, and I want it to be centered, how can I do this? Already tried to find options, but it never happened! ..
Closed due to the fact that off-topic participants MedvedevDev , Vadim Ovchinnikov , Air , andreymal , nörbörnën May 27 '18 at 9:06
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Vadim Ovchinnikov, andreymal, nörbörnën
|
2 answers
The topic is really trashed on thousands of resources, but since here they are looking for an answer:
* { margin: 0; padding: 0; } body, html { height: 100%; } .container { display: flex; align-items: center; justify-content: center; height: 100%; } <div class="container"> <p>Lorem ipsum</p> </div> |
For text alignment, text-align with center is responsible.
|
text-align: center;however, if the block is centered, thenmargin: auto;- HamSter