Sun, 2015-11-08 21:10
Hi there:
I'm centering a block of text inside a div, it is working but I note that the result is not exactly centered, instead it is offset vertically by 2px aprox.
the code is this:
<body> <div class="outer"> <div class="inner"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p></div> </div> </body>
.outer { width: 300px; height: 300px; line-height: 300px; text-align: center; background:#3C6; } .inner { display: inline-block; vertical-align: middle; line-height: normal; background:#FF0; }
If I reset margin and padding to 0 for all elements, the offset ramains.
What could I be missing here?
Thanks in advance,
Rafael
Mon, 2015-11-09 07:34
#1
Hi Rafael, I don't see in the
Hi Rafael,
I don't see in the code why it would be out.
Personally I would probably ignore it.
If you need to fix it you could try margin-top:-1px for the .inner p.
Mon, 2015-11-09 08:22
#2
It may be the space below the
It may be the space below the baseline that is reserved for descenders, e.g. qypgj.
cheers,
gary