Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Scrollable Table in HTML

Posted on 2015-02-18
6
Medium Priority
?
79 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
  • 3
  • 2
6 Comments
 
LVL 34

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
Industry Leaders: 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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

916 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