我有一个包含在div中的内容,我正在尝试根据用户的偏好进行缩放。 我使用Louis Remi's transform.js来实现这一点。
然而,当我这样做时,它会将内容推到远离div的顶部(在缩小时切断内容)或远离容器的底部(在放大时留下很多空白空间)。
我想知道是否有任何方法可以将内容推到固定在div的顶部?
这里是一个jsfiddle示例。 现在它处于0.50缩放状态,显示内容位于屏幕中央,上下留下很多空间。
HTML
<div id="reportContainer">
<div id="zoomMe">
<div id="content1" class="fillerBox"> </div>
<div id="content2" class="fillerBox"> </div>
<div id="content3" class="fillerBox"> </div>
<div id="content4" class="fillerBox"> </div>
<div id="content5" class="fillerBox"> </div>
</div>
</div>
CSS
#reportContainer { margin: 0;padding:15px;overflow-y:scroll;overflow-x:hidden; border:2px solid black;}
.fillerBox { background-color:#ccc;border:1px dashed #000;height:1500px;width:910px;margin:0 auto;margin-bottom:30px; }
JS
$(document).ready(function() {
$("#reportContainer").height($(window).height()-50);
$("#zoomMe").css('transform', 'scale(.50)' );
});
$("#zoomMe").css({ 'transform' : 'scale(.50)', 'top' : '-2280px' });
- 你有什么建议可以让它自适应容器大小并进行缩放吗? - bryan