【发布时间】:2012-06-21 21:11:21
【问题描述】:
我确定我在这里忽略了一些东西,但无法解决。我的第二个内联块 div 上方有空白,只有当右侧 div 中的“文本此处”长度小于左侧时,才会出现这种情况。
jsFiddle:http://jsfiddle.net/B2S4r/2/(您需要使 HTML 视图更宽才能看到它们并排显示)
<div style="border-top: 1px dashed black; display: inline-block; width: 250px; margin-bottom: 10px; margin-right: 10px; margin-top: 0;">
<div style="height: 50px; padding-top: 2px; padding-bottom: 2px; text-align:right; font-size: 11px;">
<div style="display: block; width: 80px; height: 50px; float: left; background-color: #cdcdcd; background-position: left center;">
</div>
<span class="main_header" style="font-size: 21px; margin: 0;">Title</span>
<br />
Subtitle
</div>
<div style="display:block; background-color: #efefef; height: 75px; padding: 5px; font-size: 12px;">
Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here Text here
</div>
</div>
<div style="border-top: 1px dashed black; display: inline-block; width: 250px; margin-bottom: 10px; margin-right: 10px; margin-top: 0;">
<div style="height: 50px; padding-top: 2px; padding-bottom: 2px; text-align:right; font-size: 11px;">
<div style="display: block; width: 80px; height: 50px; float: left; background-color: #cdcdcd; background-position: left center;">
</div>
<span class="main_header" style="font-size: 21px; margin: 0;">Title</span>
<br />
Subtitle
</div>
<div style="display:block; background-color: #efefef; height: 75px; padding: 5px; font-size: 12px;">
Text here Text here Text here Text here Text here Text here Text here Text here Text
</div>
</div>
【问题讨论】:
-
首先,我会从摆脱所有内联 css 开始。很难看出到底发生了什么。
-
点了。我通常从不使用内联 css,但在找到正确的属性之前使用它似乎更容易,然后将它们分开。
-
我看不出问题和答案中给出的 jsfiddle 有什么区别。它们看起来都一样。