html - 第二个内联 block div 上方的空白

标签 html css

我确定我在这里忽略了一些东西但无法解决。我的第二个内联 block div 上方有空白,只有当右侧 div 中的“此处文本”长度小于左侧时才会出现这种情况。

jsFiddle:http://jsfiddle.net/B2S4r/2/ (您需要使 HTML View 变宽才能看到它们并排显示)

<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>​

最佳答案

vertical-align 的默认值为 baseline,当应用于不同高度的 block 时,它通常是不需要的。

应用 top 的值将解决您的问题。这是一个工作 fiddle :http://jsfiddle.net/PhilippeVay/B2S4r/3/ (因为你的 fiddle 里没有样式表,只有内联 CSS,所以我什至不会尝试找到如何瞄准右边的那个)

关于html - 第二个内联 block div 上方的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11107583/

相关文章:

javascript - 激活时如何删除文本装饰。我有以下代码,但链接带有下划线

html - 使用选项卡时保持焦点循环在表单的输入上,而不是移动到第二个表单

php - CodeIgniter 遇到 PHP 错误

html - 显示 :table when width of content is more then outer div

javascript - 如何在新创建的元素上的 .map 函数内传递自定义函数?

javascript - 水平翻转html网页而不是文本

html - Bootstrap.css 与我的自定义设置冲突

javascript - 如何创建一个搜索栏,用于下拉 SQL 数据库中的元素列表

html - 重新创建 Google 主页 (html/css) : Questions regarding positioning

html - Div 隐藏在 Chrome 中