我有一个外部分区(固定高度和宽度),其中包含两个垂直放置的分区,占用相同的宽度和全高。我希望它们同时在垂直方向上滚动,但只有第二个是水平滚动。因此,第一个div只在水平滚动时被冻结。在div中,我使用d3使用基于SVG的图形进行数据可视化。
提琴
<style>
div.Container{
height: 250px;
border: 2px solid #F00;
width: 600px;
padding: 3px;
overflow: auto;
/* POSITION */
position:fixed;
}
div.Const{
border: 2px solid #0F0;
width: 200px;
height: 400px;
float:left;
position:absolute;
}
div.Main{
border: 2px solid #00F;
width: 800px;
height: 200px;
margin-left: 220px;
top:0px;
float:left;
}
</style>
<body>
<div id="Container" class="Container">
<div id="Const" class="Const">
</div>
<div id="Main" class="Main">
</div>
</div>
</body>
<script>
$('#Container').scroll(function() {
$('#Const').css('left', $('#Container').scrollLeft());
});
</script>