【发布时间】:2016-09-13 23:42:26
【问题描述】:
当我悬停链接时,会显示一个absolute pseudo element。
我制作了 div overflow-y: scroll,那些 pseudo element 外部视图无法显示,他们仍在使用未计算 scroll 的位置。
Chrome 有这个问题,Firefox 运行良好。
这里有两张图片:
.blog .widget-panel {
height: 400px;
width: 200px;
margin: 20px;
position: fixed;
}
.blog .widget-panel > div {
overflow-x: hidden;
overflow-y: auto;
height: 100%;
}
.blog .widget-panel .tag-box .tag-block {
display: block;
line-height: 28px;
border-bottom: 1px dotted rgba(0,0,0,0.1);
padding: 7px;
color: #666;
background-color: #fff;
}
.blog .widget-panel .tag-box .tag-block:hover,
.blog .widget-panel .tag-box .tag-block.selected {
background-color: #38B7EA;
color: #fff;
}
.blog .widget-panel .tag-box.block .tag-block[data-title]:hover:after {
content: attr(data-title);
position: absolute;
z-index: 20;
white-space: nowrap;
background: rgba(85,85,85, 0.9);
padding: 4px 8px;
color: #fff;
font-size: 14px;
line-height: 18px;
margin-top: 2.8em;
}
.blog .widget-panel .tag-box .tag-block .count{
float: right;
}
<div class="blog">
<div class="panel panel-default widget-panel">
<div class="tag-box block">
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
</div>
</div>
</div>
【问题讨论】:
-
不要在单个网页中一次又一次地使用相同的 ID,例如
all-tags。如果您将position: absolute设置为任何 div 或标签,并希望相对于父标签显示它,那么您应该将position: relative设置为父标签。 -
谢谢。当我将
position: relative添加到父级 (.tag-block) 时,它会显示一个水平滚动条,也不会像我想要的那样显示。 -
当将
position: relative;添加到.tag-block时,标题会被overflow隐藏。喜欢这里:https://jsfiddle.net/dp70zv5o/2/
标签: css google-chrome scroll css-position