Jquery 在网页上的特定位置设置背景图像
我正在尝试向背景图像添加一些动画。我想把它升到一个特定的高度,我该怎么做Jquery 在网页上的特定位置设置背景图像,jquery,html,css,Jquery,Html,Css,我正在尝试向背景图像添加一些动画。我想把它升到一个特定的高度,我该怎么做 .riseImages { position: absolute; width: 100%; height: 300px; overflow: hidden; z-index: 4; background-image: url("img/page1/bg shapes.png"); background-repeat: repeat; background-siz
.riseImages {
position: absolute;
width: 100%;
height: 300px;
overflow: hidden;
z-index: 4;
background-image: url("img/page1/bg shapes.png");
background-repeat: repeat;
background-size: 350px;
opacity: 0.3;
border-left: 1px solid blueviolet;
border-right: 1px solid blueviolet;
background-size: 350px 300px;
}
.topRise {
top: 0px;
left: 0px;
}
.bottomRise {
top: 500px;
left: 0px;
}
是,使用
背景位置
最简单的解决方案是将边距设置为负值。即使在添加背景位置后,边距也可能不起作用。函数topRise(){$(“.topRise”)。动画({top:-300px},30000,topSet);};函数botRise(){$(“.bottomRise”).animate({top:“0px”},30000,botSet);};函数topSet(){$(“.topRise”).css({/“display”:“none”,“top”:“0px”});topRise();};函数botSet(){$(“.bottomRise”).css({/“display”:“none”,“top”:“300px”});botRise();};botRise();顶升();实际上,我希望背景图像在网页上从一个特定的高度向上上升到一个特定的高度
.riseImages
{
background-position: value;
position: absolute;
width: 100%;
height: 300px;
overflow: hidden;
z-index: 4;
background-image: url("img/page1/bg shapes.png");
background-repeat: repeat;
background-size: 350px;
opacity: 0.3;
border-left: 1px solid blueviolet;
border-right: 1px solid blueviolet;
background-size: 350px 300px;
}
.topRise {
top: 0px;
left: 0px;
}
.bottomRise {
top: 500px;
left: 0px;
}