Issue
I'm trying to create an HTML
table where its height is limited and the left side stays fixed while scrolling horizontally (and the table body is scrollable horizontally) but not fixed while scrolling vertically (the left side will be scrollable with the rest of the table).
fixed scrollable
1 body content
2 body content
3 body content
4 body content
. .
. .
. .
I found this solution, but it only addresses horizontal scrolling. In Eamon Nerbonne jsFiddle example, adding a height: 150px;
to the div will demonstrate the bug I'm trying to solve.
Is it possible to achieve it only using HTML and CSS?
Solution
Adding another div to the Eamon Nerbonne's solution, gave me the following solution:
Basically the solution is, if you add another parent div that controls the flow of the secondary div might give you a go.
<div class="first">
<div class="second">
<table>
<tr><td class="headcol">1</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">2</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">3</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">4</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">5</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">6</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">7</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">8</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
<tr><td class="headcol">9</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
</table>
</div>
</div>
I added style for the outer div like this:
div.first {
width: auto;
overflow-y: scroll;
overflow-x: hidden;
height: 150px; /* this is the height that you expect to contain */
padding-bottom: 1px;
position: absolute;
left:0;
top:auto;
}
Answered By - Nagaraj Tantri
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.