Currently, in the layout, when hovering over new characters, they fill the box causing it to expand in height due to width restrictions.
Without the use of JavaScript, one would need to lift the hovered-over element from the DOM using absolute positioning.
However, this action may result in the elements below it moving up the page, which is not desired.
It's a challenging situation without JavaScript, and I'm unable to find a solution that doesn't involve duplicating content on the screen. The provided code works but could use some cleanup :)
* {
margin: 0px;
padding: 0px;
}
.box {
width: 170px;
}
.wrapper {
position: relative;
}
.box h3 {
position: relative;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
}
.hidden {
display: none;
}
.wrapper:hover > .hidden {
display: block;
color: white;
position: absolute;
top: 0;
left: 0;
height: auto;
width: 100%;
background-color: blue;
}
<div class="box">
<div class="wrapper">
<h3>Really long text that will wrap</h3>
<div class="hidden">Really long text that will wrap</div>
</div>
<h2>Text Below its dfg asdrg sdh zxdh xcgh .</h2>
</div>