Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html table extending off the screen

I have a table, which extends off the screen to the right (it has fixed with and this width is larger than screen width). Browser automatically creates scroll bar at the bottom. How can I instruct browser, while displaying this table in "invisible" area to the right, not to create a scroll bar? The purpose of this exercise that this table will be scrolled left using Javascript, showing its contents to the right which is initially off the screen.


If I set "overflow:hidden" for the "body", all other content becomes unscrollable in case it does not fit to the screen (e.g. in 1024 browser, as content is optimized for 1280). I need only this table (which is inside two DIVs) not to create browser scroll bar...

Code looks like the following way

<div style="position:relative;overflow:hidden;width:1500px">
    <div style="float:left">
        <table style="table-layout:fixed;width:1500px">
            <tr>
                <td style="width:300px">
                    aaa
                </td>
                <td style="width:300px">
                    bbb
                </td>
                <td style="width:300px">
                    ccc
                </td>
                <td style="width:300px">
                    ddd
                </td>
                <td style="width:300px">
                    eee
                </td>
            </tr>
        </table>
    </div>
</div>
like image 997
Anonymous Avatar asked Dec 27 '25 21:12

Anonymous


1 Answers

Add the following CSS rule:

body
{
  overflow-x:hidden;
}

EDIT: After seeing your comments, and that the table is within a div I suggest the following. Lets say your markup is:

<div class="tablecontainer">
  <table />
</div>

Use the following CSS rule:

div.tablecontainer
{
  overflow-x:hidden;
}
like image 142
Curtis Avatar answered Dec 30 '25 13:12

Curtis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!