网格视图从容器 div 中分离出来



我对divs和css相当陌生,所以请温和:)我在一个比屏幕宽的div 中有一个网格视图,而不是外部div 扩展以适应它,它爆发了。如果我在外部div 上放溢出,我会得到一个滚动条,但我不想在div 中使用滚动条,我想允许用户使用浏览器 scollbar 滚动。这是我的代码,任何帮助将不胜感激。谢谢

  #page
{
    background-color:#EEEEEE;
    vertical-align:middle;
    text-align:center;
    margin:5px 5px 5px 5px;
    overflow:auto; 
}
#OuterDiv
{
    border:solid 1px #000000;
    background-color:#ffffff;
}
#ContentDiv
{
    padding:5px 5px 5px 5px;
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="~/Styles/stylesheet1.css" rel="stylesheet" type="text/css" />
</head>
<body id="page">
    <form id="Form1" method="post" runat="server">
    <div id="OuterDiv">
        <div id="ContentDiv">
           <!-- <asp:Image ID="Image1" runat="server" ImageUrl="~/downArrow.gif" Width="2500px" Height="5px" />-->
            <asp:GridView ID="GridView" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="PID" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:BoundField DataField="PID" HeaderText="Property_ID" 
                         ReadOnly="True"  />
                    <asp:BoundField DataField="Client_ID" HeaderText="Client_ID"  />
                    <asp:BoundField DataField="aID" HeaderText="aID" />
                    <asp:BoundField DataField="Type_ID" HeaderText="Type_ID"  />
                    <asp:BoundField DataField="Status_ID" HeaderText="Status_ID"  />
                    <asp:BoundField DataField="Condition_ID" />
                    <asp:BoundField DataField="Quality_Check" HeaderText="Quality_Check"  />
                    <asp:BoundField DataField="Letter_ID" HeaderText="Letter_ID"  />
                    <asp:CheckBoxField DataField="Access" HeaderText="Access" />
                    <asp:BoundField DataField="Strike" HeaderText="Strike" />
                    <asp:BoundField DataField="No" HeaderText="No"  />
                    <asp:BoundField DataField="Built" HeaderText="Built"  />
                    <asp:CheckBoxField DataField="Resend" HeaderText="Resend"  />
                    <asp:BoundField DataField="Revisit" HeaderText="Revisit" />
                </Columns>
            </asp:GridView>
        </div>
    </div>
    </form>
</body>
</html>

查看源...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title><link href="Styles/stylesheet1.css" rel="stylesheet" type="text/css" /></head>
<body id="page">
    <form method="post" action="WebForm1.aspx" id="Form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="9kht/xXvq8Ky7JiNUYvFSN1I/TZ5M2MHLJ3V81g2Hxcph4cd9c2B2uqNJdJGHTlx5DCKDYjQUKj+efSTbulissrkRqZtOSk3u9pRKi7qV+X8jHXf2yQc3euHfKr9AfonKd0Tgw0dS08KUuRNbNmL9RFOmKStSVmDfFnBxrXWxSrfmvcdh0DgsGiZ+7r96G4wodp/xlN3DwvK1qpWj9W+w9lUnhuyeznkjJjZnwg2K2x3c0h+37jl2GQm97WoeBzBi4I60ESQxWSp0X4UZ42s/AjN67NYe9PkW/Laou73b9fJGstscuZ9IsR/dklggQaFEeYBAfPb6MrWhgMC96uVDdOLamD5GeYWIPf1AkdC3pgHFGKg05wUsTIJwmjZTu71ivvMxzW3BzbOMc7DPNijFtJ+EvciCZZ5eQtdbF6yH8d0Wf62aH8yhdaT1qdC1/QfSEnX9TV+lSZIF7cJ5bjIsWR3fHmDOkFppHmO5FRq3aE4A+QUxtq3ygjP/OHdUScZF4r4i22q/diMhA7bGkEFYu7vgXDPqA1lYpymI0AtdB7CY9Wq3JZv9nTG1L+rPu0hjGbTc+Uo6pZbVgcBw+BmCKg4ZlBMCkNh0qaYIRqmplb7786MwlE2kHyCO5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xc7pGO6Ro7GWLUcngrhNYLeJLqwQtvKhoL4QuFbQh7iCsDYThJGs9GwLfJgxRdmGgXWmErF0wdEy6VOkweJd14hxxwpV5bDCBEzZldd1ipVlFQyYQdm8GLvjOAx3oUMCdxUZXDmfhHefq9tSEmjO5Da8nbMjo756gnjJKUzCeYZeCVlRo6Ye67WmyhKR/53cU0U1o2ZvfyXzJj2gyQtv/y9ewGl2iuR05H8XfZAnuvYRCjecVScSJJFId1Luol/jDYFctUlHqfmRawwEA9yZ/q1L5d3z+rFm9KJpNOm6jy8tKTWPdQfSP/L0DquKjMwQje3udrnsL1Y/K4hTXRMR+lXMJ3vFgN08J3kdM2nTLrZw6Sa6ARnxWfyuKYkTEhi75v9jjeOYX7NnZHWKN4QxWWy+v4fe6wcNMM57gc5ntzAETMkH3eSMPt66bPUiKKWGU53tD3ygv/zZyn1Dl4WybNlkXe+G7eo9xoKuCQ0k1tvreAwoo31BWOETUipA==" />
</div>
<div class="aspNetHidden">
    <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="qZYIU/6LTVycyZg1nqgPf4PbztGHnGb9E+xlV5NDyZ3cqihuPsgLkGWcAzTeRY10hUK3zDCNWEpQi2JdzOyDt39AjxvqUvbs7YoY5ckwVtJAPZVp2X6S1akdqvI4KIGb0hIt5ieX8iPX60SCD9VGvhOPgp3KbqQB22aGkEzjeUK9pI1Z2dsUeO/uNr38hIVSLvmiWInqePwmo0DUISlKva53o51aiVTkQ+lcausxMZBGLUexClrLM3WvV44wNC9z" />
</div>
    <div id="OuterDiv">
        <div id="ContentDiv">

            <div>
    <table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
        <tr>
            <th scope="col">Property_ID</th><th scope="col">Client_ID</th><th scope="col">aID</th><th scope="col">Type_ID</th><th scope="col">Status_ID</th><th scope="col">Condition_ID</th><th scope="col">Quality_Check</th><th scope="col">Letter_ID</th><th scope="col">Access</th><th scope="col">Strike</th><th scope="col">No</th><th scope="col">Built</th><th scope="col">Resend</th><th scope="col">Revisit</th>
        </tr><tr>
            <td>22</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_0" type="checkbox" name="GridView1$ctl02$ctl00" disabled="disabled" /></span></td><td>0</td><td>3</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_0" type="checkbox" name="GridView1$ctl02$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>23</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_1" type="checkbox" name="GridView1$ctl03$ctl00" disabled="disabled" /></span></td><td>0</td><td>3</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_1" type="checkbox" name="GridView1$ctl03$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>24</td><td>1</td><td>24</td><td>10</td><td>21</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_2" type="checkbox" name="GridView1$ctl04$ctl00" disabled="disabled" /></span></td><td>0</td><td>2</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_2" type="checkbox" name="GridView1$ctl04$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>25</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_3" type="checkbox" name="GridView1$ctl05$ctl00" disabled="disabled" /></span></td><td>0</td><td>2</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_3" type="checkbox" name="GridView1$ctl05$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>26</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_4" type="checkbox" name="GridView1$ctl06$ctl00" disabled="disabled" /></span></td><td>0</td><td>3</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_4" type="checkbox" name="GridView1$ctl06$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>27</td><td>1</td><td>24</td><td>38</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_5" type="checkbox" name="GridView1$ctl07$ctl00" disabled="disabled" /></span></td><td>0</td><td>2</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_5" type="checkbox" name="GridView1$ctl07$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>28</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_6" type="checkbox" name="GridView1$ctl08$ctl00" disabled="disabled" /></span></td><td>0</td><td>3</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_6" type="checkbox" name="GridView1$ctl08$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>29</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_7" type="checkbox" name="GridView1$ctl09$ctl00" disabled="disabled" /></span></td><td>0</td><td>3</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_7" type="checkbox" name="GridView1$ctl09$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>30</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_8" type="checkbox" name="GridView1$ctl10$ctl00" disabled="disabled" /></span></td><td>0</td><td>2</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_8" type="checkbox" name="GridView1$ctl10$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr><tr>
            <td>31</td><td>1</td><td>24</td><td>10</td><td>1</td><td>0</td><td>&nbsp;</td><td>0</td><td><span class="aspNetDisabled"><input id="GridView1_ctl00_9" type="checkbox" name="GridView1$ctl11$ctl00" disabled="disabled" /></span></td><td>0</td><td>2</td><td>&nbsp;</td><td><span class="aspNetDisabled"><input id="GridView1_ctl01_9" type="checkbox" name="GridView1$ctl11$ctl01" disabled="disabled" /></span></td><td>0</td>
        </tr>
    </table>
</div>

        </div>
    </div>
    </form>
</body>
</html>

尝试从 gridview 的父div 中删除任何溢出属性,并将其添加到您的 CSS 中

body{ overflow:auto; }

删除了外部div 并将其属性放入内容div。添加了显示:表;到ContentDiv,

这是一个JSFiddle,我想它正在按预期工作。

相关内容

  • 没有找到相关文章

最新更新