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
Release: 2024-12-04 11:19:09
Original
668 people have browsed it

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>
Copy after login
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);
}
Copy after login

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!

source:dev.to
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template