css - 超出div宽度范围的文字进行省略号省略,如何在鼠标移上去以后显示完整的内容?
PHP中文网
PHP中文网 2017-04-17 12:59:05
0
7
1040

使用了

p.titleholder { 
font-family: ms sans serif, arial; 
font-size: 8pt; 
width: 100; 

text-overflow: ellipsis;    
overflow: hidden; 
white-space: nowrap; 
} 

如何在鼠标移上时,或者使用其他方式来显示完整信息?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(7)
Peter_Zhu

The simplest way is to add the title attribute to the tag and assign the content to be displayed.

<p title="全部内容">部分内容</p>
阿神

p.titleholder:hover {
text-overflow:inherit;
overflow: visible;
white-space: pre-line;
}

http://www.w3school.com.cn/tiy/t.asp?f=css3_text-overflow_hover

左手右手慢动作
p.titleholder:hover {
  overflow: visible;
}

Not sure if this effect is what you want?

巴扎黑

Is that so?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    p { width:100px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
    p:hover { width:auto; }
  </style>
</head>
<body>
  <p>算哒垃圾死分拉萨机aldj都是sd</p>
</body>
</html>
左手右手慢动作

Add a title attribute~

迷茫

If the default style of the title does not meet product expectations, customization is a good choice; see demo

Ty80

Write multiple classes directly and add the class when the mouse passes over it. Just remove the styles that exceed the ellipsis display

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template