2013-07-10 61 views
-2

好的,我正在尝试制作一个全屏表格,点击消失并显示身体本身。我发现在互联网上下面的代码,我修改了一点已经:点击删除表格

<!DOCTYPE html> 
    <html> 
     <head> 
     <script type="text/javascript"> 

      /****************************************** 
      * Popup Box- By Jim Silver @ [email protected] 
      * Visit http://www.dynamicdrive.com/ for full source code 
      * This notice must stay intact for use 
      ******************************************/ 

      var ns4=document.layers 
      var ie4=document.all 
      var ns6=document.getElementById&&!document.all 

      function hidebox(){ 
      crossobj=ns6? document.getElementById("showimage") : 
      document.all.showimage 
      if (ie4||ns6) 
      crossobj.style.visibility="hidden" 
      else if (ns4) 
      document.showimage.visibility="hide" 
      } 

     </script> 
     </head> 
     <body> 
     <p>You can see this after a click</p> 
     <div id="showimage" style="position:absolute;top:0;left:0;right:0;bottom:0"> 
      <table border="0" width="100%" height="100%" bgcolor="#000080" onClick="hidebox();return false">   
      </table> 
     </div> 
     </body> 
    </html> 

它到目前为止的工作 - 该表的背景是蓝色的,当你点击它,它揭示了其背后的文本。但是我想要做的是将表格的背景设置为IMAGE。

我应该提到我不是程序员,这是我第一次这样做。我试图使一个样式与

table.background { background: url("URL here" no-repeat; } 

,并在不同的地方“这里的URL”改变BGCOLOR背景=,它只是没有工作。 请帮助我,我真的很喜欢做这个工作!

+0

松散的.background,只能用table {}。 – user1721135

+0

@ user1721135作为回答发布 – Barmar

+0

如果我在 user2291950

回答

0

像这样选择元素的CSS:

table { 
background: url("path/file.jpg"); 
background-repeat:no-repeat; 
} 

一切以点状

.background { 

} 

将意味着一类在HTML中存在像这样

<table class="background"> 

BTW您的js都搞砸了,用这个:

/****************************************** 
    * Popup Box- By Jim Silver @ [email protected] 
    * Visit http://www.dynamicdrive.com/ for full source code 
    * This notice must stay intact for use 
    ******************************************/ 

    var ns4=document.layers; 
    var ie4=document.all; 
    var ns6=document.getElementById&&!document.all; 

    function hidebox(){ 
    crossobj=ns6? document.getElementById("showimage") : 
    document.all.showimage; 
    if (ie4||ns6) 
    crossobj.style.visibility="hidden"; 
    else if (ns4) 
    document.showimage.visibility="hide"; 
    } 
+0

我尝试过这种方式,但它不适合我。如果您将我的代码复制到.html文件中,请更改您建议更改的内容并将其打开 - 是否适用于您?我的浏览器可能有问题吗? – user2291950

+0

适合我看演示:http://jsbin.com/avihuc/1/edit – user1721135

+0

非常感谢你现在的作品:)我仍然有点困惑,以前它是如何不工作,但我会想办法!谢谢 – user2291950

1

你的表没有class“background”,你的CSS不正确。您还缺少背景规则中的右括号。用你的HTML,应该更像:

table { 
    background: url("url here") no-repeat; 
} 
+0

对不起,这只是这个网页上的一个错字,我在代码中正确地写了它,但它仍然不能正常工作 – user2291950

+1

我将你的代码复制到一个HTML文件中,并使用上面提供的CSS,它适用于我。使用Chrome。 – digiliooo

+0

谢谢你现在的工作,谢谢你的帮助:) – user2291950