簡體   English   中英

如何將表格寬度設置為等於頁面寬度

[英]How to set the table width equal to the page width

我的aspx頁面中有以下html代碼。 我想將表格寬度設置為100%,這似乎不起作用。 我在哪里做錯了嗎?

<table style="width:100%">
     <tr>
        <td height="15">
            <div id="menu">
                <ul>
                   //page menus are being placed here
                </ul>
            </div>
        </td>
    </tr>
</table>

我在這張桌子下面還有一個網格。 gridview延伸到右,但是這個表不同樣附帶gridview

確保您有正確的html文檔:

<!doctype html>
<html>
<head>
<title>Test</title>
<style>
*{margin:0;padding:0;}//clear default browser margin & padding from all elements
html,body{width:100%;position:relative;}
</style>
</head>
<body>
<table style="width:100%">
     <tr>
        <td height="15">
            <div id="menu">
                <ul>
                   //page menus are being placed here
                </ul>
            </div>
        </td>
    </tr>
</table>
</body>
</html>

編輯:

標記沒有自動應用的CSS規則。 但是該標記在所有瀏覽器上都有默認的邊距,因此您所要做的就是使用以下CSS將它們削掉:

body {
    margin: 0px;
}

點擊下面的“運行代碼段”按鈕進行檢查。

 body { margin: 0px; } 
 <table style="width:100%; border:1px solid black;"> <tr> <td height="15"> <div id="menu"> <ul> //page menus are being placed here </ul> </div> </td> </tr> </table> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM