-2

好的,所以我正在尝试制作一个全屏表格,单击该表格会消失并显示身体本身。我在互联网上找到了以下代码,并且已经对其进行了一些修改:

    <!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" ,但它不起作用。请帮帮我,我真的很想完成这项工作!

4

2 回答 2

1

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

table {
    background: url("url here") no-repeat;
}
于 2013-07-10T19:56:40.953 回答
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";
    }
于 2013-07-10T19:51:59.773 回答