You can just add height:auto
to the hover
state and it’ll work just fine:
JS Fiddle
.name{
width:120px;
color: #0079c1;
height: 2em;
line-height: 1em;
font-size: 20px;
font-weight: 400;
text-overflow: ellipsis;
margin-bottom: 12px;
cursor: pointer;
word-break: break-all;
overflow:hidden;
white-space: nowrap;
}
.name:hover{
overflow: visible;
white-space: normal;
height:auto; /* just added this line */
}
<p class="name">
Lorem ipsum lorem ipsum lorem ipsum ipsum lorem ipsum
</p>
<span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem voluptate deserunt consequatur velit, alias ullam fuga aspernatur, ut doloremque eos fugiat quo a accusamus minus distinctio quasi, recusandae excepturi molestiae.
</span>