0

在 html 页面中,我有一个 div 元素,该元素将在页面加载时从另一个文件中填充。

考虑以下代码片段:

<script type="text/javascript">
 $(document).ready( function()
 {
   $( "#index_articles" ).load( "./index-data.txt" );
 });

 <div id="index_articles"></div>

 <b> DUMMY LINES: only for mark the end of loaded data </b>

当页面准备好时,文件index-data.txt被加载到index_articlesdiv 中。当然,从文件加载数据会导致 divindex_articles增加它的高度尺寸。

我期望的是index_articlesdiv 下面的页面元素将重新定位在修改后的 div 的末尾,而我所拥有的是 divindex_articles与其他元素重叠。

我在这段代码中缺少什么?

我在 Fedora 17 上使用 jquery 1.8 和 firefox 14.0.1

4

1 回答 1

0

正如 Lix 和 Peter 所建议的,错误出现在 css 中,但在参数 height 中发现:

  height: 70px;

删除 height 参数后, index_articles 中的文本不再与其他组件重叠。

#index_articles {
  display: block;
  width: 70%;
  height: 70px;
  margin-left: 120px;
  border-radius: 10px;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  font-size: small;
  text-indent:1em;
   color: green; 
  opacity: 0.8;
}

现在的问题是:为什么如果我设置了 height 参数,似乎这会阻止对 dom 页面中其他组件的引用?

于 2012-08-16T15:04:24.440 回答