【发布时间】:2022-11-21 12:40:10
【问题描述】:
当我将鼠标悬停在第一个 div 上以显示全文时,第二个 div 的位置会更改为位于第一个 div 之后。我需要第二个 div 保留在原处,第一个 div 的文本与它重叠。
演示:https://codepen.io/adivity/pen/OJEzoPm
<html>
<body>
<div class="container">
<div>1) This is the full title that I want to be revealed. That is super duper long and totally will overlap the next div.
</div>
<div>2) This is the full title that I want to be revealed. That is super duper long and totally will overlap the next div.
</div>
<div>3) This is the full title that I want to be revealed. That is super duper long and totally will overlap the next div.
</div>
</div>
</body>
</html>
.container {
max-width: 100px;
margin: 0 auto;
}
.container div {
height: 80px;
background-color: grey;
}
.container div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.container div:hover {
overflow: visible;
white-space: normal;
z-index: 2;
max-width: 100px;
}
【问题讨论】:
-
为什么会有一个随机的
position: absolute;?