css 创建一个元素内容的过长隐藏和鼠标放上去显示的样式

78 阅读1分钟

    <style>
        table td {
            /*防止自动换行*/
            white-space: nowrap;
            /*隐藏超出部分*/
            overflow: hidden;
            /*用省略号代替*/
            text-overflow: ellipsis;
        }

        table td[title]:hover::before {
            /* 鼠标悬停时显示 */
            content: attr(title);
            position: absolute;
            margin-top: 26px;
            min-width: 200px;
            border: 1px #aaaaaa solid;
            border-radius: 10px;
            background-color: #ffffcc;
            padding: 12px;
            color: #000000;
            font-size: 14px;
            z-index: 1;
        }
    </style>