Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 使背景动画具有响应性的问题_Css - Fatal编程技术网

Css 使背景动画具有响应性的问题

Css 使背景动画具有响应性的问题,css,Css,我为我的背景制作了一个动画,但没有反应,我不知道如何制作。 我使用Bootstrap4和CSS作为我的主要设计资源 我起诉的CSS如下: /* Animation GLitch */ .animation { position: relative; width: 100%; height: 100vh; background: url("https://images.unsplash.com/photo-1487174244970-cd18784bb4a4?ixl

我为我的背景制作了一个动画,但没有反应,我不知道如何制作。 我使用Bootstrap4和CSS作为我的主要设计资源

我起诉的CSS如下:

/* Animation GLitch */
.animation {
    position: relative;
    width: 100%;
    height: 100vh;
    background: url("https://images.unsplash.com/photo-1487174244970-cd18784bb4a4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2252&q=80");
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    overflow: hidden;
}
.animation:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("https://images.unsplash.com/photo-1487174244970-cd18784bb4a4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2252&q=80");
    opacity: 0.5;
    mix-blend-mode: hard-light;
    display: block;
}
.animation:hover:before {
    animation: animate 0.2s linear infinite;
}
@keyframes animate {
    0% {
        background-position: 0 0;
        filter: hue-rotate(0deg);
    }
    10% {
        background-position: 5px 0;
    }
    20% {
        background-position: -5px 0;
    }
    30% {
        background-position: 15px 0;
    }
    40% {
        background-position: -5px 0;
    }
    50% {
        background-position: -25px 0;
    }
    60% {
        background-position: -50px 0;
    }
    70% {
        background-position: 0 -20px;
    }
    80% {
        background-position: -60px -20px;
    }
    81% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 0;
        filter: hue-rotate(360deg);
    }
}
动画由两张相同的图片组成,它们产生了这种小故障效果,但我不知道如何使其响应

它在这里工作的飞贼:


我尝试使用大小调整,但它正在修改我的效果我希望在所有屏幕上保持相同的效果

我不太明白您希望它以何种方式响应,但尝试在
背景:url(…)
之后添加这些行,两次都是:

background-repeat: no-repeat;
background-size: cover;
查看有关
背景大小
属性的更多信息


也是你可能感兴趣的第二个答案。

你是否考虑过使用媒体查询()?我试着不能用JavaScript找到一个好的解决方案,你可以做<代码>让宽度=窗口。window.onresize=fixGlitch;函数fixGlitch(){document.querySelector('main').style.transform=`scale(${window.innerWidth/width});`width=window.innerWidth;}很抱歉,这个脚本实际上没有做任何事情