2013-07-10 60 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