css 父 div 和子 div 不能正常播放

标签 css jquery css-float

我有一个父 div,里面并排有大约六个 div。一切正常,除非我向其中添加了一点 jQuery。

现在父 div 不会像以前那样展开。我将父 div relative 和子 div absolute 但父 div 只是不会拉伸(stretch)开。

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>

最佳答案

我不太确定这 http://jsfiddle.net/thebabydino/CRRV5/正是您想要的,但它有效并且可以进行调整。

关于css 父 div 和子 div 不能正常播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10762008/

相关文章:

html - float :none; not working with media queries

javascript - 在 PaperJS 中平移大 svg 的问题

html - 如何获得任意大小的 html 文档的高质量可移植渲染?

php - 在 localhost 中执行代码时,php 文件中的部分 html 文件没有出现

html - 如何设置并排可缩放 div 的样式

css - 当 float 元素处于其固定宽度同级之间时,如何使它填充剩余的水平空间?

javascript - Chrome 和同位素 - 页面大小

jquery - 使用 google OAuth 2.0 成功登录后无法获取用户信息

javascript - 使用 jQuery 插件验证图像尺寸

javascript - 找不到 Django 页面,ajax 请求无法正常工作