CSS图像背景未对保证金生效

时间:2013-04-13 21:05:50

标签: css css3

为什么我的背景图像不会在边缘区域重复?
如何使保证金背景透明或类似的东西?
因此它会显示背景页面。

这是问题的图像(红线只是我为调试添加的div边框):
enter image description here

这是我的CSS代码:

html { 
  background: url(/img/bg.png); 
  background-repeat:repeat;
}

table.display {
    margin: 0 auto;
    clear: both;
    width: 100%;
    table-layout:fixed;
}

#dt_div  {
    border: red 4px dashed;
    width:96%;
    margin-left:auto;
    margin-right:auto;
}



和HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico" />

        <title>DataTables Editor example</title>
        <style class="include" type="text/css">
            @import "support/bootstrap/css/bootstrap.css";
            @import "support/bootstrap/dataTables/dataTables.bootstrap.css";
            @import "css/customTable.css";
        </style>

        <script class="include" type="text/javascript" charset="utf-8" src="../../../media/js/jquery.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="../../../media/js/jquery.dataTables.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="../../TableTools/media/js/TableTools.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="../../TableTools/media/js/ZeroClipboard.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="../media/js/dataTables.editor.js"></script>

        <script class="include" type="text/javascript" charset="utf-8" src="support/bootstrap/js/bootstrap.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="support/bootstrap/dataTables/dataTables.bootstrap.js"></script>
        <script class="include" type="text/javascript" charset="utf-8" src="support/bootstrap/dataTables/dataTables.editor.bootstrap.js"></script>

        <script class="include" type="text/javascript" charset="utf-8" src="./js/custom.js"></script>
        <script type="text/javascript">
            aDataInitial = '<?php  echo json_encode($stack);?>';
        </script>
    </head>
    <body id="c_body" style="border: red 4px dashed;">
        <div id="mContainer" style="border: red 4px dashed;">
            <div id="dt_div">
                <table class="table table-striped table-bordered display" id="example">
                    <thead>
                        <tr>
                            <th style="text-align: center;">Data</th>
                            <th style="text-align: center;">Tema</th>
                            <th style="text-align: center;">V&iacute;nculo</th>
                            <th style="text-align: center;">Empresa</th>
                            <th style="text-align: center;">Sub contratada</th>
                            <th style="text-align: center;">NDP</th>
                            <th style="text-align: center;">CH</th>
                            <th style="text-align: center;">HHT</th>
                            <th style="text-align: center;">Ger&ecirc;ncia</th>
                            <th style="text-align: center;">&Aacute;rea Solicitante</th>
                            <th style="text-align: center;">CC</th>
                            <th style="text-align: center;">Rateio</th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="spacer"></div>

        </body>
    </html>     

1 个答案:

答案 0 :(得分:2)

我认为你正在寻找background-image

html { 
  background: url(/img/bg.png); 
  background-repeat:repeat;
}

应该是

body { 
  background-image: url('/img/bg.png'); 
  background-repeat: repeat;
}

您还可以将所有选项合并到background,如MDN文档中所示:https://developer.mozilla.org/en-US/docs/Web/CSS/background(使用background时,您仍然可以指定background-imagebackground-repeat等等。覆盖后。)