简体   繁体   English

具有隐藏滚动条的Lion / Mountain Lion上的CSS悬停错误

[英]CSS hover bug on Lion/Mountain Lion with hidden scrollbars

I have a list where a button shows up inside each list item when you hover over it. 我有一个列表,当您将鼠标悬停在每个列表项上时,按钮会显示在每个列表项内。 The button is on the right edge of each list item. 该按钮位于每个列表项的右侧。 This works fine when the list doesn't need to scroll, but it doesn't work properly when scrolling is needed on Lion/Mountain Lion in Safari with hidden scrollbars. 当列表不需要滚动时,此方法效果很好,但在带有隐藏滚动条的Safari中,在Lion / Mountain Lion上需要滚动时,此方法无法正常工作。 It seems the CSS hover state of the underlying item is removed when the mouse is over the hidden scrollbar area so the button disappears. 当鼠标悬停在隐藏的滚动条区域上时,基础项目的CSS悬停状态似乎已删除,因此该按钮消失了。

I've reproduced the problem here: 我在这里重现了这个问题:

http://jsfiddle.net/upsT3/ http://jsfiddle.net/upsT3/

Does anyone know of a solution/workaround for this? 有谁知道解决方案/解决方法吗?

Markup: 标记:

<div id="list1" class="list">
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
</div>
<br />
<br />
<div id="list2" class="list">
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>   
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div>
    <div>Foo<button>a</button></div> 
</div>

CSS: CSS:

.list {
    height: 200px;
    width: 300px;
    border: 1px solid gray;
    overflow: auto;
}

.list div {
    padding: 5px 0px 5px 5px;
    border-bottom: 1px solid #eee;
}

.list div:hover {
    background: #eee;
}

.list button {
    float: right;
    display: none;    
}

.list div:hover button {
    display: block;
}

Adding position: relative; 新增position: relative; to .list seems to get rid of the hover problem in Safari, but the click issue persists. .list似乎摆脱了Safari中的悬停问题,但单击问题仍然存在。

http://jsfiddle.net/zZWPq/ http://jsfiddle.net/zZWPq/

Oddly enough, the containing div registers the click, while button does not. 奇怪的是,包含div注册点击,而button没有注册。 Hiding the scrollbar altogether would of course get rid of the problem, but that's bad UX, strongly discouraged and really shouldn't be considered an option. 完全隐藏滚动条当然可以解决问题,但是那是糟糕的UX,强烈建议不要这样做,实际上不应该将其视为一种选择。 Will report back if I find something else though. 如果我发现其他问题,将报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM