需要使用的CSS()jQuery函数来应用这些样式,帮助需要 [英] Need to apply those Styles using .css() Jquery Function, help needed

查看:105
本文介绍了需要使用的CSS()jQuery函数来应用这些样式,帮助需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的风格需要

body{
      background: url("img/Background_Home.jpg") no-repeat center center fixed;
                        -webkit-background-size: cover;
                        -moz-background-size: cover;
                        -o-background-size: cover;
                        background-size: cover;


      margin:0;
    }

这是我去..

 function actualizar_fondo(imagen){
            $('body').css({"background":"url(img/"+imagen+".jpg)"});
            $('body').css({"background":"no-repeat center center fixed"});
            $('body').css({"-webkit-background-size":"cover"});
            $('body').css({"-moz-background-size":"cover"});
            $('body').css({"-o-background-size":"cover"});
            $('body').css({"background-size":"cover"});



       }

结果:甚至没有背景图片(但只有第一线,工作)

Result: Not even background image (but with only first line, works)

我猜...问题在第二行?

i guess... problems are in second line?

推荐答案

第二行是overiding第一行的结果。两者都可以结合起来。

Second line is overiding the result of first line. Both can be combined.

function actualizar_fondo(imagen){
        $('body').css({"background":"url(img/"+imagen+".jpg) no-repeat center center fixed"});
        $('body').css({"-webkit-background-size":"cover"});
        $('body').css({"-moz-background-size":"cover"});
        $('body').css({"-o-background-size":"cover"});
        $('body').css({"background-size":"cover"});
}

这篇关于需要使用的CSS()jQuery函数来应用这些样式,帮助需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆