单击以删除表

时间:2013-07-10 19:44:10

标签: javascript html css

好的,所以我试图制作一个全屏幕表,点击消失后显示身体本身。我在互联网上找到了以下代码,我已经修改了一下:

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

            /******************************************
            * Popup Box- By Jim Silver @ jimsilver47@yahoo.com
            * 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>

它到目前为止工作 - 表的背景是蓝色的,当你点击它时它会显示它背后的文字。但我想要做的是使表格的背景成为一个图像。

我应该提到我不是程序员,这是我第一次这样做。我尝试用

制作样式表
    table.background { background: url("URL here" no-repeat; }

并在不同的地方将bgcolor更改为background =“URL here”,但它无法正常工作。 请帮帮我,我真的很想做这个工作!

2 个答案:

答案 0 :(得分:1)

您的表格没有“背景”类,您的CSS不正确。您还缺少后台规则中的右括号。使用HTML,它应该更像是:

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

答案 1 :(得分:0)

在css中选择这样的元素:

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

一切都像点

.background {

}

意味着一个类存在于html中,如此

<table class="background">

顺便说一句,你的js搞砸了,请使用:

    /******************************************
    * Popup Box- By Jim Silver @ jimsilver47@yahoo.com
    * 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";
    }