css – 为什么webkit过滤器上的堆叠顺序更改悬停?

在应用webkit过滤器时,我注意到堆叠顺序存在一个奇怪的问题.为什么当我将鼠标悬停在图像上时,堆叠顺序会发生变化?

我宁愿不必使用z-indexing来解决这个问题,因为它打破了其他网站元素.

这是我的JSFiddle
http://jsfiddle.net/r13ycy1p/

请原谅荷马,我只需要一张图片.

编辑:如何反转效果以阻止绝对位置div被隐藏?

这是我的HTML

<ul>
<li>
    <a href="#">
        <div class="slide-content">
            <div class="slide-title">
                <h1>hello world</h1>
            </div>
            <div class="slide-desc">
                <p>a description about something</p>
            </div>
        </div>
        <img src="http://img4.wikia.nocookie.net/__cb20130920142351/simpsons/images/e/e9/Pic_1187696292_8.jpg"/>

    </a>
</li>
</ul>

CSS

li {
list-style:none;    
}

.slide-content {
position:absolute;
color:red;
top:50px;
}

li a:hover img{
-webkit-filter: grayscale(100%); /* For Webkit browsers */
}

解决方法

这是因为非none以外的值建立了 stacking context.这在 spec中记录(当前处于工作草案状态):

07002

This specification defines a set of CSS properties that affect the
visual rendering of elements to which those properties are applied;
these effects are applied after elements have been sized and
positioned according to the Visual formatting model from [CSS21]. Some
values of these properties result in the creation of a containing
block,and/or the creation of a stacking context
.

该规范还指出:

07003

A computed value of other than none results in the creation of a stacking context [CSS21] the same way that CSS opacity does.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


css的bordercolor属性怎么使用
CSS中contain属性的作用和语法
深入学习响应式布局框架:适合初学者到专家的详尽指南
CSS3选择器优先级规则
margin-top用法
选择最适合您的响应式布局框架:综合评估不同工具
使用CSS中的content属性
设计一个无缝适应不同屏幕尺寸的网站
如何处理CSS样式的层叠问题
探究最佳响应式布局框架:竞争激烈!
学习基本数据类型的快速入门:掌握常用操作技巧
CSS中float布局介绍
一同探讨响应式布局的益处
掌握响应式设计的益处,让网页在不同设备上展现完美适配!
可能导致CSS加载失败的原因有哪些?
各种基本数据类型的全面操作指南
CSS3选择器是否用于设计界面结构?
响应式布局优化移动设备适配的策略与实用技巧
伪元素怎么清除浮动
利用CSS响应式布局创作独特网页设计的设计技巧