I am trying to set text at a center of a box when a number is not present, and when number is present text should go to top and number at the bottom.
I am able to show with number box correctly but without number box is vertical alignment does not work.
I am an HTML new bee.
Can someone help me here? I have looked at various articles and they point to using table cell and vertical alignment as middle. I tried that as well, I think the red box does not have text in the middle.
Here is an example.
http://jsfiddle.net/seohh5r1/2/
<!DOCTYPE html>
<html>
<head>
<style>
.alignleft {
float: left;
}
.alignright {
float: right;
}
.even-boxes,
.odd-boxes {
height : 52px;
width : 430px;
padding-left : 20px;
display : table-cell;
vertical-align : middle;
}
.odd-boxes {
background-color:#FFCCCC;
}
.even-boxes {
background-color:#CCEBFF;
}
.surname-entry {
font-size: 25px;
font-family:"Verdana";
}
.name-entry {
font-size: 18px;
font-family:"Verdana";
}
.another-entry {
font-size: 14px;
font-family:"Verdana";
}
.number-entry {
font-size: 32px;
font-family:"Verdana";
}
</style>
</head>
<body>
<div class="odd-boxes">
<div>
<span class="surname-entry">ABCDEFGH<span>,</span></span>
<span class="name-entry"> PQRSTU</span>
<span class="number-entry alignright" style="margin-right:20px">K</span>
</div>
</div>
<div class="even-boxes">
<div>
<span class="surname-entry">ABCDEFGH<span>,</span></span>
<span class="name-entry"> PQRSTU</span>
<span class="number-entry alignright" style="margin-right:20px">K</span>
<div class="another-entry">[1234567890101]</div>
</div>
</div>
</body>
</html>