2013-01-07 70 views
0

我找不到或找不到。在一个较小的div中溢出一个更大的div

在带有溢出的div里面,我放了另一个带有缩放选项的div。 我喜欢将内部div放在外部div中,当它通过缩放变得更大时,但像margin:0px auto;不起作用。

<div id="container" style="float:left; overflow:scroll; width:644px; height:702px;"> 
    <div id="zoomimg" style="zoom:54%;"> 
    <img src="plattegrond.jpg" class="map" usemap="#leige"> 
    </div> 
</div> 

注意! zoom:54%(644x702)可以用JS以100%和150%进行更改。

回答

0

我有类似的问题。你'有效'失去了你的父母div作为一个参考点,以中心的子div。我把它集中在自己身上来解决它。这应该工作:

$(window).load(function(){ 
    width = $("#container").width(); 
    height = $("#container").height(); 
    margL = $(".map").width()/2 -width/2; 
    margT = $(".map").height()/2 - height/2; 
    $(".map").css('margin-left',-margL) 
    $(".map").css('margin-top',-margT) 
}) 

这是做here

+0

不工作。 .map必须#zoomimg定位div,但滚动条不会进入中间滚动左侧... – Harry