Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scrollable Table in HTML

Posted on 2015-02-18
6
Medium Priority
?
78 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

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 84

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

715 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