为什么添加text-overflow:inherit;才有效果?代表什么意思?
来源:1-6 新文本属性(text-align-last和text-overflow)
迷失的小麦
2019-11-14 14:54:27
<!DOCTYPE html>
<html>
<head>
<style>
div.test
{
white-space:nowrap;
width:12em;
overflow:hidden;
border:1px solid #000000;
}
div.test:hover
{
text-overflow:inherit;
overflow:visible;
}
</style>
</head>
<body>
<p>如果您把光标移动到下面两个 div 上,就能够看到全部文本。</p>
<p>这个 div 使用 "text-overflow:ellipsis" :</p>
<div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div>
<p>这个 div 使用 "text-overflow:clip":</p>
<div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div>
</body>
</html>
1回答
同学你好,text-overflow属性值没有inherit。老师在课上讲过这个属性。在视频的5分59秒处
如下:
在鼠标移入时,文字能够显示出来,是因为设置了overflow: visible;
因为属性值设置的不对,所以hover时text-overflow这个属性是不生效的。
同学可以按照下面的步骤进行查看:
首先:按f12打开控制台
然后:根据下方步骤操作:
祝学习愉快~
相似问题