gpt4 book ai didi

html - 寻找更好的方法来设置可调整大小的背景 Css3/HTML/mootools

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

我找到了一些代码,可以让我像这样调整浏览器窗口大小并适本地重置图像 h+w

    html {
background: url(css/images/600.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

我不清楚如何更改此元素的背景,因为以下行找不到 html 元素

window.addEvent('domready', function () {
$(this).setStyle('background', 'url(css/images/600.jpg) no-repeat center center fixed;');
});

如何通过mootools脚本更改html标签的背景图片?为 html 元素设置一个类会更好吗?如果是这样,我如何按类引用元素?

最佳答案

在 domready 函数中,thiswindow 元素而不是 html 元素

应该是这样的:

window.addEvent('domready', function () {
this.document.html.setStyle('background', 'url(css/images/600.jpg) no-repeat center center fixed');
});

希望对你有帮助

顺便说一句: 我不会为 html 元素提供样式,它会导致 IE 出现问题。最好为 body 标签设置样式或创建包装器 div

关于html - 寻找更好的方法来设置可调整大小的背景 Css3/HTML/mootools,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7593685/

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