css - 为什么我的 HTML aside block 添加了一个多余的结尾段落分隔符?

标签 css html

我有这个标记:

CSS

aside {
    color: cornsilk;
    font-family: 'Bookman Old School', Candara, Calibri, sans-serif;
}

HTML

<aside style="margin:4px;padding:4px;border:1px solid forestgreen;">
    Some criticize <cite>Huckleberry Finn</cite> because it uses "the N word." While it <em>is</em> an ugly word, that is the way many people spoke in the time and place represented by this novel.

<p>Should it be censored out, or replaced with another word?</p>

<p><cite>Huckleberry Finn</cite> has been criticized from the "git-go" for various reasons (and in fact, Twain rather rejoiced at this than fretted, knowing that calls for his book to be banned would actually draw more attention to it and increase sales).</p>

    <p>Early on, some readers and reviewers were shocked, not by the novel's use of "the N word" (which they may not have considered objectionable or perhaps not even have really noticed, due to its ubiquitous usage throughout the country) but rather for its "low" subject matter and earthy humor, which was considered too crude and rough for "polite society" and sometimes for the very reason that Jim is portrayed sympathetically - as a real person with feelings and thoughts, and not as a minstrel show caricature.</p></aside>

如你所见here (或者,如果您是 HTML/CSS 专家,也许可以预想),在上面显示的 HTML 部分的末尾有一个多余的行或段落分隔符。其他“旁白”/注释不会表现出这种行为。这是其中之一:

<aside style="margin:4px;padding:4px;border:1px solid forestgreen;">
That is to say, 40-50 years ago at the time Twain wrote it, which was in the 1880s; in other words, the time period covered in "Huck Finn" is the 1830s and 1840s, between the War of 1812 and the Civil War.
</aside>

我需要做什么才能取消尾随中断?

最佳答案

正如@sdcr 在评论中告诉您的那样,问题的产生是因为 aside 特别有一个 p 元素,您在底部看到的空间是由于到段落的 margin-bottom

为了避免看到它,只需从 aside 的最后一段中删除 margin-bottom:

aside p:last-child {
    margin-bottom: 0;
}

看到它正在更新你的 jsfiddle:http://jsfiddle.net/tL4s1hjr/24/

关于css - 为什么我的 HTML aside block 添加了一个多余的结尾段落分隔符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28788927/

相关文章:

html - Apple 风格的 CSS spritesheet 菜单中的白色间隙和中断

css - 2k 分辨率屏幕和 4k 分辨率屏幕和 8k 分辨率的响应式 CSS

html - 链接 html css 和图像

html - 没有背景图片的全尺寸侧边栏

javascript - 在 html 页面中嵌入日志文件

javascript - 为什么我的 Bootstrap 模态窗口在 Opera 中不起作用?

javascript - javascript onclick 时防止列表元素移动

css - 选择元素在IE中总是向上打开

javascript - 在javascript中没有for循环的情况下从父级删除所有div子级

html - Tailwind CSS 自定义宽度和高度不起作用,尽管可以使用直接 CSS 应用相同的值