我有一个父div,里面有大约六个div。除非我添加了一点jQuery,否则一切正常。
现在父div不像以前一样扩展。我创建了父div relative
而子div absolute
但是父div不会拉开。
的jQuery
$(".child").click(function() {
var mypos, otherpos, $this;
// Move to the target element
$this = $(this);
pos = $this.offset();
otherpos = $('selector_for_other_element').offset();
pos.left = otherpos.left - pos.left;
pos.top = otherpos.top - pos.top;
$this.animate({
left: pos.left + "px",
top: pos.top + "px"
});
});
CSS
<style type="text/css">
.child{
width: 250px;
height: auto;
float: left;
padding: 10px 5px 10px 0px;
background-color: #fff;
position: absolute
}
.parent {
width: 770px;
height: auto;
float: left;
padding: 10px 0px 0px 10px;
background-color: #fff;
position: relative;
overflow: none;
}
</style>
HTML
<div class="parent">
<div class="child">content</div>
<div class="child">>content</div>
<div class="child">>content</div>
<div class="child">>content</div>
<div class="child">>content</div>
<div class="child">>content</div>
</div>