JSFiddle - React, Tailwind, and code Playground
by Yandy Viera
HTML
<p>Go hover to see a higher text</p>
<div class="center-div-content">
<div class="center-div">
this is
</div>
</div>
<p>of course you can place the large text directly inside the div, the meta :after is only to show how it looks with a small text and with a big one</p>
<div class="center-div-content">
<div class="center-div">
this is a long long long long long long long long long long long long text
</div>
</div>
CSS
.center-div-content{
position: relative;
display: inline-block;
width: 200px;
height: 200px;
background: #f5f5f5;
}
.center-div {
position: absolute;
width: 100%;
top: 50%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
transform: translateY(-50%);
}
.center-div-content:hover .center-div:after{
content:'a long long long long long long long long long long long long text'
}