I have a div
with width 100px and height 100px, but I want the text to be aligned in the middle of the div
.
I have used text align center for the horizontal alignment, for vertical alignment i tried using vertical-align
property. It's not working, then I used line-height
for making the content exactly in the middle of the document. The line height will vary for each and every element depending upon the content. Is there any appropriate solution for this issue?
<!DOCTYPE html>
<html>
<head>
<style>
.dragg-elem div {
width: 100px;
height: 100px;
border: 2px solid #ccc;
display: inline-block;
line-height: 90px;
text-align:center;
}
</style>
</head>
<body>
<div class="dragg-elem">
<div id="one">1</div>
<div id="two">2</div>
<div id="three">3</div>
<div id="four">4</div>
<div id="five">5</div>
</div>
</body>
</html>