我有一个具有内联样式的div元素,用于设置背景。我想做的是添加另一个背景图像,通过
::before
伪类,并将其作为Rellax.js为视差效果启动的类。
迄今为止的结果:
rellax.min.js:14 Rellax: The elements you're trying to select don't exist.
这是有道理的,因为我认为伪元素不在DOM中。背景确实像我计划的那样相互叠加。
问题:
是否可以引用元素的伪属性?
HTML:
<div class="right bttk-cta-bg" style="background:url(/wp-content/uploads/2022/11/Arrow-Down-BG.png) repeat; background-position: top left">
::Before
Rellex.js
<script>
// Also can pass in optional settings block
var rellax = new Rellax('.bttk-cta-bg::before', {
speed: -2,
center: false,
wrapper: null,
round: true,
vertical: true,
horizontal: false
});
</script>
CSS:
.bttk-cta-bg::before {
content: '';
background: url(/wp-content/uploads/2022/11/up-arrows.png);
position: absolute;
top: 0px;
left: 0px;
}