0

I am trying to center part of the text on my Mpdf page, but it just won't center.

CSS:

#centrar{
margin-right:auto;
margin-left:auto;
}

html:

<div id='centrar'>
<img src='imagens/logo.png' width='100' height='100'>
<h3>Curriculo</h3>
Nome: $nome $apelido <br>
E-Mail: $email <bR>
Função: $funcao <br>
Área: $area <br>
Chefia: $chefe <br>
</div>

The path to the file is defined correctly.

Is there any other way to center a part of the text?

Thanks

user3536315
  • 17
  • 2
  • 7

1 Answers1

1

margin: auto won't center an element horizontally unless you also set a width that's less than 100%. E.g.

#centrar{
    margin-right:auto;
    margin-left:auto;
    width: 80%;
}
ralph.m
  • 13,468
  • 3
  • 23
  • 30
  • How can I add text in center of the A4 page? – Rohan Hapani Apr 17 '20 at 12:54
  • @RohanHapani — More info needed. Is this a web page? Are you printing it? Theoretically, the above code works for any page size, but you need to be clearer about what your situation is. – ralph.m Apr 18 '20 at 00:33
  • Actually, I run php code and download pdf. I want to set cover page on first index. Text should be display in center of the page from all side. I mean center of top, left, bottom, right. – Rohan Hapani Apr 20 '20 at 09:44
  • @RohanHapani — Try something like this: https://stackoverflow.com/questions/19026884/flexbox-center-horizontally-and-vertically – ralph.m Apr 20 '20 at 23:27