问题涉及到这个小提琴这里:http://jsfiddle.net/k3QAC/1/我和朋友们正在做一个项目CSS定位 - 绝对/相对/?
我有三个相同的部分标记,看起来像这样:
<section id="1">
<h3>This is a heading.</h3>
<p>This is 1 of 1 p tags.</p>
<p>This is 1 of 2 p tags.</p>
<p>This is 1 of 3 p tags.</p>
</section>
<section id="2">
<h3>This is a heading.</h3>
<p>This is 1 of 1 p tags.</p>
<p>This is 1 of 2 p tags.</p>
<p>This is 1 of 3 p tags.</p>
</section>
<section id="3">
<h3>This is a heading.</h3>
<p>This is 1 of 1 p tags.</p>
<p>This is 1 of 2 p tags.</p>
<p>This is 1 of 3 p tags.</p>
</section>
当你将鼠标悬停在任何在H3标签我的小提琴,我想< p>标签显示在完全相同的位置。如果你已经完成了第一节h3的话,那么p标签显示从顶部开始。如果您将鼠标悬停在第2节h3上,则p标签显示在完全相同的位置。与#3 h3部分相同。
非常感谢彻底的答案。现在很清楚:) – mcranston18 2012-07-29 23:32:07
是否可以在不调整HTML的情况下完成Demo 2? – mcranston18 2012-07-29 23:43:07
@ mcranston18是的,但是您必须对段落应用固定高度,或者使用javascript来动态设置每个段落的顶部偏移量,以使它们不重叠。如果你可以编辑你的标记,这肯定是最简单的和推荐的解决方案 – jackwanders 2012-07-30 00:37:14