更改背景图片在rainy.js中不起作用

时间:2020-08-14 19:54:18

标签: html jquery css node.js jquery-ui

我从this URL下载了Zip文件。 当我打开默认文件时,它可以工作。 但是,我尝试仅更改背景图像;它没有用,什么也没显示。

错误消息:

  • Access to image at 'demo2.html:1 xxx.jpg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https.
  • Failed to load resource: net::ERR_FAILED

HTML:

       <script src="./js/rainyday.min.js"></script>
        <script>
            function run() {
                var image = document.getElementById('background');
                image.onload = function () {
                    var engine = new RainyDay({
                        image: this
                    });
                    engine.rain([
                        [3, 2, 2]
                    ], 100);
                };
                image.crossOrigin = 'anonymous';
                image.src = '\myimage.jpg'; //I changed
            }

        </script>

CSS:

.jumbotron {
  padding: 120px 25px;
  text-align: center;
  background-image: url('\myimage.jpg');//I changed
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 0 100%;
  color: #fff;
  text-shadow: 0 1px 3px #000;
}

0 个答案:

没有答案