Method 1 - Using Parent Container
To achieve the desired result, you need to include a parent container and apply the CSS property
display: flex; align-items: center
to it. The code snippet below demonstrates how this can be implemented:
.parent {
border: 1px solid #000;
display: flex;
align-items: center;
height: 100px;
width: 100px;
}
.text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="parent">
<div class="text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit, esse!</div>
</div>
Method 2 - No Parent Container Required
You can also achieve the same result by simply adding the CSS properties
display: table-cell; vertical-align: middle; max-width: 100px;
. See the code snippet below for reference:
.text {
display: table-cell;
vertical-align: middle;
width: 100px;
max-width: 100px;
height: 100px;
border: 1px solid #000;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit, esse!</div>