Home >Web Front-end >CSS Tutorial >Show full text on hover with text-overflow: ellipsis

Show full text on hover with text-overflow: ellipsis

DDD
DDDOriginal
2024-12-04 11:19:09610browse

Show full text on hover with text-overflow: ellipsis

Inspired by this post where someone would

want to have an active title property for only those list items that trigger the text-overflow rule on the list. So you can hover the mouse over any text that is truncated and see a tooltip of its full text

Here is my approach.

<div>
    <span><span>Some longer text visible on hover</span></span>
    <span><span>Another longer text visible on hover</span></span>
    <span><span>Short text</span></span>
</div>
div {
    display: grid;
    grid-template-columns: 100px 100px 100px;
}
div>span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
span>span:hover {
    position: absolute;
    background-color: rgba(5, 255, 255, 1);
}

The above is the detailed content of Show full text on hover with text-overflow: ellipsis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn