如何显示此JavaScript突出显示范围 之间 页脚背景和页脚中的元素?
增加 z-index 其中的元素似乎无法实现这一点。
z-index
示例一-突出显示显示在页脚后面,背景部分透明。
https://codepen.io/jklemon17/pen/KoydPy
.footer { background-color: rgba(70, 70, 70, .5); position: fixed; bottom: 0; width: 100%; padding-top: 50px; padding-bottom:100px; /* z-index: -2; */ }
示例二-突出显示显示在页脚元素的顶部。
https://codepen.io/jklemon17/pen/xWPGBm
.footer { background-color: grey; position: fixed; bottom: 0; width: 100%; padding-top: 50px; padding-bottom:100px; z-index: -2; }
谢谢
在这种情况下,最好是 append 突出显示页脚的元素,而不是正文,这样 z-index 更容易处理。在代码中更改此选项:
append
const footer = document.querySelector('.footer'); highlight.classList.add('highlight'); footer.append(highlight);
https://codepen.io/anon/pen/wmPKEy