I have a div
set to display:block
. (90px
height
and width
) and I have some text inside.
I need the text to be aligned in the center both vertically and horizontally.
I have tried text-align:center
, but it doesn't do the horizontal part so I tried vertical-align:middle
but it didn't work.
Any ideas?
you can try very easy code for this
codpen link http://codepen.io/santoshkhalse/pen/xRmZwr
One of The Best approach is use flex property at parent div and add margin:auto property to element tag
This works for me (tested ok!)
html:
css:
you can choose other values then 50% fi. 25% to center at 25% of parent