I have two divs which have overflow set to auto and they contains bootstrap panels.
I am trying to make both divs scroll synchronously which is infact working.
But there are two issues I m facing.
1) Text is getting wrapped so I used white-space:nowrap;
which worked but then caused 2nd issue.
2) Now as soon as I scroll the header is not extended till the body
Can anyone please point out how to fix the issue. jsfiddle
Thanks!!!
var $divs = $('#generalContainer, #dataContainer');
var sync = function(e){
var me = $(this);
var $other = $divs.not(me).off('scroll');
$divs.not(me).each(function (index) {
$(this).scrollLeft(me.scrollLeft());
});
setTimeout(function () {
$other.on('scroll', sync);
}, 10);
}
$divs.on( 'scroll', sync);
.panel-heading .chevron:after {
content: "f078";
}
.panel-heading.collapsed .chevron:after {
content: "f054";
}
#generalContainer, #dataContainer{
width: 1050px;
height: 300px;
overflow: auto;
}
.panel-body{
font-size: 7pt;
white-space:nowrap;
}
#generalContainer{
}
#dataContainer{
}
.general-head-col-width{
width: 200px;
padding: 5px 10px 10px 5px;
}
.general-col-width{
width: 620px;
padding: 5px 10px 10px 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
<div id="generalContainer" >
<div class="panel panel-primary">
<div class="panel-heading clearfix" data-toggle="collapse" data-target="#generalInfo"> General <i class="chevron fa fa-fw"></i></div>
<div class="panel-body" id="generalInfo">
<table>
<tbody>
<tr>
<td class="general-head-col-width" ><span class="Caption">Number</span></td>
<td class="general-col-width"><span>00110027</span></td>
<td class="general-col-width"><span>00110032</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110126</span></td>
<td class="general-col-width"><span>00110126</span></td>
<td class="general-col-width"><span>00110131</span></td></tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Type</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Name</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<tr>
<td class="general-head-col-width" ><span class="Caption">PA</span></td>
<td class="general-col-width"><span>1413-Ovenware</span></td>
<td class="general-col-width"><span>1511-Dinnerware and serving</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>1711-Outdoor dining tables</span></td>
<td class="general-col-width"><span>1711-Outdoor dining tables</span></td>
<td class="general-col-width"><span>0934-Textiles for small children</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Another Option</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Supplier</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>20774-OOO Xxxxxx</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>17987-Xxxxx. ABCDEF ghi</span></td>
<td class="general-col-width"><span>-</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Type1</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Final</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Final</span></td>
<td class="general-col-width"><span>Immediate</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Status</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Date</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2011-02-11</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2009-11-24</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>2009-11-03</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2013-10-18</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Latest Update</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2015-12-17</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-10-30</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">No</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>5</span></td>
<td class="general-col-width"><span>4</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>5</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Edition</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>4</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>6</span></td>
<td class="general-col-width"><span>6</span></td>
<td class="general-col-width"><span>1</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Validity</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2016-02-28-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2015-04-14-</span></td>
<td class="general-col-width"><span>-</span></td></tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Date1</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>-</span></td></tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="dataContainer">
<div class="panel panel-info">
<div class="panel-heading collapsed" data-toggle="collapse" data-target="#RequiredCP">Package <i class="chevron fa fa-fw"></i></div>
<div class="panel-body collapse" id="RequiredCP">
<table>
<tbody>
<tr>
<td class="general-head-col-width" ><span class="Caption">Number</span></td>
<td class="general-col-width"><span>00110027</span></td>
<td class="general-col-width"><span>00110032</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110046</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110051</span></td>
<td class="general-col-width"><span>00110126</span></td>
<td class="general-col-width"><span>00110126</span></td>
<td class="general-col-width"><span>00110131</span></td></tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Type</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
<td class="general-col-width"><span>ABC</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Name</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item. This is a sample item.</span></td>
<td class="general-col-width"><span>This is a sample item. This is a sample item. This is a sample item.</span></td>
<tr>
<td class="general-head-col-width" ><span class="Caption">PA</span></td>
<td class="general-col-width"><span>1413-Ovenware</span></td>
<td class="general-col-width"><span>1511-Dinnerware and serving</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>1521-Drinking glasses</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>0821-Chairs incl covers, folding chairs and benches</span></td>
<td class="general-col-width"><span>1711-Outdoor dining tables</span></td>
<td class="general-col-width"><span>1711-Outdoor dining tables</span></td>
<td class="general-col-width"><span>0934-Textiles for small children</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Another Option</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
<td class="general-col-width"><span>No</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Supplier</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>20774-OOO Xxxxxx</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>17987-Xxxxx. ABCDEF ghi</span></td>
<td class="general-col-width"><span>-</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Type1</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Final</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Immediate</span></td>
<td class="general-col-width"><span>Final</span></td>
<td class="general-col-width"><span>Immediate</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Status</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>INTERMEDIATE</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
<td class="general-col-width"><span>COMPLETED</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Date</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2011-02-11</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2009-11-24</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>2009-11-03</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
<td class="general-col-width"><span>2013-10-18</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>2009-10-02</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Latest Update</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2016-01-15</span></td>
<td class="general-col-width"><span>2015-12-17</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-10-27</span></td>
<td class="general-col-width"><span>2015-10-30</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>2015-06-09</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">No</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>5</span></td>
<td class="general-col-width"><span>4</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>5</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Edition</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>3</span></td>
<td class="general-col-width"><span>4</span></td>
<td class="general-col-width"><span>2</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>1</span></td>
<td class="general-col-width"><span>6</span></td>
<td class="general-col-width"><span>6</span></td>
<td class="general-col-width"><span>1</span></td>
</tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Validity</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2016-02-28-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2015-04-14-</span></td>
<td class="general-col-width"><span>-</span></td></tr>
<tr>
<td class="general-head-col-width" ><span class="Caption">Date1</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2016-02-27</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>-</span></td>
<td class="general-col-width"><span>2015-04-13</span></td>
<td class="general-col-width"><span>-</span></td></tr>
</tbody>
</table>
</div>
</div>
</div>
2
Answers
Update with solution:
Add display inline-block to the .panel and min-width to match your container.
You can use jQuery for this:
JSFiddle