gpt4 book ai didi

javascript - 为什么我不能删除背景附件属性?

转载 作者:行者123 更新时间:2023-11-28 14:11:14 24 4
gpt4 key购买 nike

因此,我尝试使用最大宽度为 1024 像素的媒体查询删除背景附件属性。我只是通过 background-attachment: none 来做到这一点,除了我的 devtools 闪烁错误并且该属性被划掉了吗?有什么想法吗?

https://jsfiddle.net/dfwg2nbv/1/

const ham = document.querySelector('.ham-menu');
const nav = document.querySelector('nav');
const header = document.querySelector('header');
const promise = document.querySelector('.promise');
const services = document.querySelector('.services');
const testimony = document.querySelector('.testimony');

header.style.removeProperty('background-attachment');

//detect mobile
// if ("ontouchstart" in document.documentElement) {
// removeProps(header);
// removeProps(promise);
// removeProps(services);
// removeProps(testimony);
// }

ham.addEventListener('click', animateMenu);

function animateMenu() {
nav.classList.toggle('hamburger-open');
}

// function removeProps(node) {
// node.style.removeProperty('background-attachment');
// node.style.removeProperty('background-size');
// }

最佳答案

您可以使用 jquery 删除背景:

$("header").css("background-image", "none");

例子:

https://codepen.io/seyyedmojtaba72/pen/gJqLGE

关于javascript - 为什么我不能删除背景附件属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56420266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com