在预加载程序上使用JQuery.CSS()设置CSS背景图像
我要设置:背景图像、背景大小和背景重复。。。这里的语法看起来怎么样在预加载程序上使用JQuery.CSS()设置CSS背景图像,jquery,css,background-image,preloader,Jquery,Css,Background Image,Preloader,我要设置:背景图像、背景大小和背景重复。。。这里的语法看起来怎么样 qLpercentage = $("<div id='qLpercentage'></div>").text("0%").css({ height: "40px", width: "100px", position: "absolute", bac
qLpercentage = $("<div id='qLpercentage'></div>").text("0%").css({
height: "40px",
width: "100px",
position: "absolute",
background: 'url(images/preload.gif)',
fontSize: "3em",
top: "50%",
left: "50%",
color: "#FFFFFF",
marginTop: "-" + (59 + qLoptions.barHeight) + "px",
textAlign: "center",
marginLeft: "-50px",
}).appendTo(qLoverlay);
qLpercentage=$(“”).text(“0%”).css({
高度:“40px”,
宽度:“100px”,
位置:“绝对”,
背景:“url(images/preload.gif)”,
字体大小:“3em”,
顶部:“50%”,
左:“50%”,
颜色:“FFFFFF”,
marginTop:“-”+(59+qLoptions.barHeight)+“px”,
textAlign:“居中”,
marginLeft:“-50px”,
}).附录(QLO);
当代码中有静态属性时,为什么要使javascript变得混乱
最好将它们放在单独的类中,并将其添加到元素中
那会干净得多
这样,您也可以指定背景图像、背景大小和背景重复
CSS
.overlay
{
height: "40px";
width: "100px";
position: "absolute";
background: 'url(images/preload.gif)' 50% 50% repeat-x ;
background-size: 275px 125px;
fontSize: "3em";
top: "50%";
left: "50%";
color: "#FFFFFF";
textAlign: "center";
marginLeft: "-50px";
}
Javascript
qLpercentage =
$("<div id='qLpercentage'></div>").text("0%")
.css({
marginTop: "-" + (59 + qLoptions.barHeight) + "px"
})
.addClass('overlay')
.appendTo(qLoverlay);
ql百分比=
$(“”)。文本(“0%”)
.css({
marginTop:“-”+(59+qLoptions.barHeight)+“px”
})
.addClass('覆盖')
.附录(QLO);
尝试添加以下内容:
"background-image" : "url(my-image.png)",
"background-repeat" : "...",
"background-size" : "...",
我想我是对的它是这样的:
qLpercentage = $("<div id='qLpercentage'></div>").text("0%").css({
height: "40px",
width: "100px",
position: "absolute",
backgroundImage: 'url(images/preload.gif)',
backgroundRepeat: 'repeat-x',
backgroundSize: '10px 10px',
fontSize: "3em",
top: "50%",
left: "50%",
color: "#FFFFFF",
marginTop: "-" + (59 + qLoptions.barHeight) + "px",
textAlign: "center",
marginLeft: "-50px",
}).appendTo(qLoverlay);
qLpercentage=$(“”).text(“0%”).css({
高度:“40px”,
宽度:“100px”,
位置:“绝对”,
背景图片:“url(images/preload.gif)”,
背景重复:“重复-x”,
背景尺寸:“10px 10px”,
字体大小:“3em”,
顶部:“50%”,
左:“50%”,
颜色:“FFFFFF”,
marginTop:“-”+(59+qLoptions.barHeight)+“px”,
textAlign:“居中”,
marginLeft:“-50px”,
}).附录(QLO);
您自己尝试过吗?这个问题实际上已经解决了。在CSS中,你可以背景:url(images/preload.gif)no repeat…,