One common method for centering text inside a div is to use the following CSS trick:
.center-div {
display:table-cell;
vertical-align: middle;
}
The issue arises when the text within the div varies in length and I require the container to have fixed dimensions. Attempting to adjust the CSS as follows results in unwanted behavior:
.center-div {
display:table-cell;
vertical-align: middle;
width: 100px;
height: 100px;
text-overflow: ellipsis;
}
Since it is set as a table-cell, the height of the div changes instead of overflowing. Given that my text may span multiple lines, traditional line-height methods are ineffective. Is there a way to both center the text and allow it to overflow simultaneously?
P.S. I am seeking a CSS-only solution. The content will be generated by angularjs, making it difficult to determine completion of rendering. If JavaScript is absolutely necessary, please provide a method that can be integrated seamlessly with angularjs (specifically ng-repeat).