Solved

Scrollable Table in HTML

Posted on 2015-02-18
6
75 Views
Last Modified: 2015-02-19
HI Experts,

Does anyone have a good and easy example of a HTML table where I can lock the thead and first column of each row, then I can easily specify the height and width of the table that I want and it will lock what it needs. Where, if needed, the rest of the data will scroll vertically or horizontally.

Thank you
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 40617733
have you checked out datatables?

http://www.datatables.net/
0
 

Author Comment

by:APD_Toronto
ID: 40617826
I just want it to add a scroll.

This used to work a couple of years ago, but I cannot remember how to make the headings "stick"

HTML:
<a href="index.php?action=logout"> <input type="button" value="Logout" id="button"> </a>
        <br>
        
        <div id="tbl-container">
            <table>
		
                <thead>
                    <th class="locked">User</th>
                </thead>
                
                <tr>
                    <td class="alt1">Reservations</td>
                </tr>
                <tr>
                    <td class="alt-1">User 2</td>
                </tr>
                <tr>
                    <td class="alt1">User 3</td>
                </tr>
                <tr>
                    <td class="alt-1">User 4</td>
                </tr>
                <tr>
                    <td class="alt1">User 5</td>
                </tr>
                <tr>
                    <td class="alt-1">User 6</td>
                </tr>
                <tr>
                    <td class="alt1">User 7</td>
                </tr>
                <tr>
                    <td class="alt-1">User 8</td>
                </tr>
                <tr>
                    <td class="alt1">User 9</td>
                </tr>
                <tr>
                    <td class="alt-1">User 10</td>
                </tr>
            </table>
        </div>

Open in new window


CSS:
input, select{
    font-size: 8pt;
}

div#tbl-container {
    width: 200px;
    height: 150px;
    overflow: auto;
    scrollbar-base-color:#ffeaff;
    margin: 10px auto;
}


thead th, thead th.locked	{
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    background-color: #FFFF66;
    border-right: 1px solid silver;
    position:relative;
    cursor: default; 
}
	
thead th {
    top: expression(document.getElementById("tbl-container").scrollTop-2); /* IE5+ only */
    z-index: 20;
}

thead th.locked {z-index: 30;}

td.locked,  th.locked {
    font-size: 12px;
    font-weight: bold;
    border-right: 1px solid silver;
    left: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft); /* IE5+ only */
    position: relative;
    z-index: 10;
}

.alt1 {
    background-color: white;
}
.alt-1 {
    background-color: #ccffff;
}

Open in new window

0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40617868
According to this article https://msdn.microsoft.com/en-us/library/ms537634%28v=vs.85%29.aspx , that method using 'expression' was obsoleted in IE8 and was only supported by Microsoft Jscript.  That means it didn't work in the other browsers.  I have some code from a question a couple of years ago, I'll see if I can find it.  It was a pain to make work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40617881
Here http://www.imaputz.com/cssStuff/bigFourVersion.html is one that works in Firefox, Chrome, Safari, and Opera.  It doesn't work in IE8 on this machine.  It lists a bunch of old browsers that don't support it.
0
 

Author Comment

by:APD_Toronto
ID: 40617901
That example actually serves my purpose.

Can you show me how to implement?

Thank you
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40617924
You need to save a copy of the source code for that page and strip out all the parts that you don't need.  I don't see any other way to do it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question