如何使用 Mootools 更改背景图像 css 属性?

发布于 2024-08-11 06:43:22 字数 42 浏览 3 评论 0原文

我是新手。如何使用 Mootools 更改我的背景图像 css 属性?

I am newbie。 How to changing my background-image css property using Mootools?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终止放荡 2024-08-18 06:43:22

例如,在页面加载时:

<div id="yourElement"></div>

<script type="text/javascript">
window.addEvent('domready', function() {
    $('yourElement').setStyle('background-image', 'url(path/to/your/image)');
});
</script>

Example, on page load:

<div id="yourElement"></div>

<script type="text/javascript">
window.addEvent('domready', function() {
    $('yourElement').setStyle('background-image', 'url(path/to/your/image)');
});
</script>
Oo萌小芽oO 2024-08-18 06:43:22

Element.Style 的 MooTools 文档 应该能够为您解答这个问题。

The MooTools docs for Element.Style should be able to answer this one for you.

终止放荡 2024-08-18 06:43:22
window.addEvents({
  // fire when the DOM is loaded
  domready: function(){
    // path to the image
    var pathToBackgroundImage = '/path/to/the/image.jpg';
    // set the background-image
    $(document.body).setStyle('background-image','url(' + pathToBackgroundImage + ')');
  }
});

如果您决定要淡入图像,则需要采取明显不同的方法。

window.addEvents({
  // fire when the DOM is loaded
  domready: function(){
    // path to the image
    var pathToBackgroundImage = '/path/to/the/image.jpg';
    // set the background-image
    $(document.body).setStyle('background-image','url(' + pathToBackgroundImage + ')');
  }
});

You need to take a significantly different approach if you decide you'd like to fade-in the image.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文