我在想申请滚动到我的HTML问题。 这个想法是有一个网格。 这可垂直滚动。 但我也希望有一个网格的一部分水平滚动。
作为奖励,我不希望任何可见的滚动条,我会使用的WebView使用它在Android上。
我与几个组件溢出摆弄,但我通常结束了:
- 可以水平滚动,而不是只有“数据”格全格。
- 具有2个独立的垂直滚动条两者“数据”和“标题”的div。
我的HTML:
<button id='scroll_up'>scroll up</button>
<button id='scroll_down'>scroll down</button>
<button id='scroll_left'>scroll left</button>
<button id='scroll_right'>scroll right</button>
<div id="grid">
<div id="header">
<a id='row_header'>Some Header</a>
<a class="row">1</a>
<a class="row">2</a>
<a class="row">3</a>
<a class="row">4</a>
<a class="row">5</a>
<a class="row">6</a>
<a class="row">7</a>
<a class="row">8</a>
<a class="row">9</a>
<a class="row">10</a>
<a class="row">11</a>
<a class="row">12</a>
<a class="row">13</a>
<a class="row">14</a>
<a class="row">15</a>
<a class="row">16</a>
<a class="row">17</a>
<a class="row">18</a>
<a class="row">19</a>
<a class="row">20</a>
</div>
<div id="data">
<div id="column_header">
<a class="header">h1</a>
<a class="header">h2</a>
<a class="header">h3</a>
<a class="header">h4</a>
<a class="header">h5</a>
<a class="header">h6</a>
<a class="header">h7</a>
<a class="header">h8</a>
<a class="header">h9</a>
<a class="header">h10</a>
<a class="header">h11</a>
<a class="header">h12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
<div class="row_data">
<a class="data">data 1</a>
<a class="data">data 2</a>
<a class="data">data 3</a>
<a class="data">data 4</a>
<a class="data">data 5</a>
<a class="data">data 6</a>
<a class="data">data 7</a>
<a class="data">data 8</a>
<a class="data">data 9</a>
<a class="data">data 10</a>
<a class="data">data 11</a>
<a class="data">data 12</a>
</div>
</div>
</div>
CSS的:
body {
font: 18px arial,sans-serif;
}
#grid {
display: block;
position: absolute;
top: 100px;
left: 0px;
width: 100%;
height: 517px;
margin: 0;
}
#header {
display: inline-block;
width: 25%;
height: 100%;
float: left;
overflow: auto;
}
#data {
float: left;
display: inline-block;
width: 75%;
height: 100%;
overflow: auto;
}
.row, #row_header {
display: block;
padding-left: 8px;
height: 50px;
border: 1px solid black;
text-align: center;
line-height: 50px;
}
.row_data, #column_header {
display: inline-block;
white-space: nowrap;
width: 100%;
}
.data, .header {
display: inline-block;
border: 1px solid black;
width: 20%;
}
#row_header, .header {
height: 30px;
line-height: 30px;
}
#row_header, #column_header {
text-align: center;
}
.data, .row {
height: 50px;
text-align: center;
line-height: 50px;
}
而我的JS:
$(document).ready(function() {
$('#scroll_up').click(function() {
var height = $('#grid').height();
$('#grid').scrollTo( '-=' + height + 'px', { axis:'y' } );
});
$('#scroll_down').click(function() {
var height = $('#grid').height();
$('#grid').scrollTo( '+=' + height + 'px', { axis:'y' } );
});
$('#scroll_left').click(function() {
var width = $('#data').width();
$('#data').scrollTo( '-=' + width + 'px', { axis:'x' } );
});
$('#scroll_right').click(function() {
var width = $('#data').width();
$('#data').scrollTo( '+=' + width + 'px', { axis:'x' } );
});
});
对于convienence: http://jsfiddle.net/xFPtj/1/
任何提示,我应该怎么办呢?