background:url(../images/eintop_sd.jpg) repeat-x center top;
  padding-top:55px;这段CSS 用JS动态控制代码怎么写

解决方案 »

  1.   


    document.body.style.background='url(../images/eintop_sd.jpg) repeat-x center top'; 
    document.body.style.paddingTop='55px';
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head><title>
    无标题页
    </title>
    <script type="text/javascript">
        function ChangeCss()
        {
            var div = document.all.divMain;
            //div = document.body;      //换成body即可
            div.style.background = "url(1.gif) no-repeat center top";
            div.style.paddingTop = "200";
        }
    </script>
    </head>
    <body onload="ChangeCss();">
        <form name="form1" method="post" id="form1">
        <div id= "divMain" style="width:800px; height:800px; border:solid  1px black;">
            ss
        </div>
        </form>
    </body>
    </html>