【发布时间】:2013-02-13 13:31:37
【问题描述】:
我花了一些时间从this site 上的 div 层创建了一个谱系,我得到了很好的对齐。
但是当我将文本放入其中时,无论是在 div 还是在 p 标签中,它都会将 div 层显着向下移动。
它似乎没有添加任何边距或填充或任何其他我在检查元素时可以看到的东西,而且它似乎没有影响孙 div 层。
HTML:
<div id="pedigree">
<div id="parentwrap">
<div class="parent">test</div>
</div>
<div id="childwrap">
<div class="child">
<p>Am. Ch. Kenai's Aldebaran</p>
</div>
<div class="child">
<p>pAm. Ch. Santa Clara Del Viento</p>
</div>
</div>
<div id="grandchildwrap">
<div class="grandchild">Am. Can. Ch. Ryzann's Eclipse at Kenai</div>
<div class="grandchild">Am. Ch. Timber Ridge's Abi of Kenai</div>
<div class="grandchild">Am. Ch. Sky Run Gavril Virtual Zip JC</div>
<div class="grandchild">Am. Can. Ch. Tazeb's Zena</div>
</div>
</div>
CSS:
#pedigree {
position: relative;
width: 584px;
height: 204px;
margin: 0 auto;
margin-top: 15px;
padding-bottom: 15px;
border-bottom: 1px dotted black;
}
#parentwrap {
position: relative;
display: inline-block;
margin: 0;
width:auto;
height: 205px;
}
.parent {
position: relative;
width: 190px;
height: 202px;
margin: 0px;
padding: 0px;
border: 1px solid black;
}
#childwrap {
position: relative;
display: inline-block;
margin: 0;
width: auto;
height: 205px;
}
.child {
position: relative;
width: 190px;
height: 95px;
margin: 0px;
padding: 0px;
border: 1px solid black;
margin-bottom: 10px;
}
#grandchildwrap {
position: relative;
display: inline-block;
width: auto;
height: 205px;
}
.grandchild {
position: relative;
width: 190px;
height: 46px;
margin: 0px;
padding: 0px;
border: 1px solid black;
margin-bottom: 4px;
}
.parent, .child, .grandchild {
-moz-border-radius: 35px;
border-radius: 35px;
【问题讨论】:
-
不相关,但您网站上的副本充满了拼写/语法错误。记得也要解决这个问题!
-
点将添加代码
-
如果从 div
#pedigree中删除height会改变什么吗? -
将这两个尽可能小的标记/css 等隔离开来。通常这会启发你,你可以用更集中的集合来学习。顺便说一句,根据我有限的经验,它很可能是在比容器更大的东西里面。