jquery - 是否可以制作:before fade using jquery?

标签 jquery css

所以我有一个纯粹风格的 div,带有 :before 位于图像下方,CSS 如下所示:

.the-image-div {
    width: 100px;
    height: 100px;
    box-shadow: inset 0px 0px 3px white;
    border: 1px gray solid;
    position: relative;
    z-index: 3;
}

.image-stack {
    width: 100px;
    height: 100px;
    background: white;
    border: 1px solid gray;
    position: relative;
    top:3px;
    left: 3px;
    z-index: 2;
}

.image-stack:before {
    content: " ";
    width: 100px;
    height: 100px;
    background: white;
    border: 1px solid gray;
    box-shadow: inset 0px 0px 1px white;
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 1;
}

如果 jquery 不仅可以选择图像堆栈,还可以单独选择 :before ,那就太好了。目标是在图像堆栈本身之后几毫秒内使其褪色。有想法吗?

最佳答案

JavaScript 无法与伪元素交互。相反,我会将 :before 应用于随后添加到元素的类,然后使用 CSS 过渡使其淡入。

关于jquery - 是否可以制作:before fade using jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14144950/

相关文章:

php - Json 返回 'null'

javascript - 如何使用 AJAX 将对象数据数组插入数据库

Jquery/CSS 重置样式

html - 子固定定位元素未与父相对定位元素对齐

css - Angular Material Snackbar 位置

javascript - 使用 jquery 隐藏和取消隐藏搜索 div

javascript - D3.js 中的鼠标悬停问题,包含路径元素并在刷过焦点后更改工具提示数据?

HTML/CSS Paypal 按钮

html - 从浏览器打印时我的 CSS 文件没有加载

html - 下拉列表中的元素不可点击