h 标签前面添加自定义标签之后显示一段空白是为什么?

新手上路,请多包涵

求助 h 标签前面添加自定义标签之后显示一段空白。

就是上面这样,怎样才能去掉那段空白。
自定义标签是这样的:<hbe-prefix></hbe-prefix>
没有宽度和高度。

阅读 1.7k
2 个回答
✓ 已被采纳新手上路,请多包涵

我已经解决了这个问题。这个方法看起来比较笨,但它起到了作用。
使用 nth-child(2) 对首次出现的 h 标签强制清除浏览器作出的行动。

#post h1:nth-child(2) {
    margin-block-start: 0em !important;
}
#post h2:nth-child(2) {
    margin-block-start: 0em !important;
}
#post h3:nth-child(2) {
    margin-block-start: 0em !important;
}
#post h4:nth-child(2) {
    margin-block-start: 0em !important;
}
#post h5:nth-child(2) {
    margin-block-start: 0em !important;
}
#post h6:nth-child(2) {
    margin-block-start: 0em !important;
}

看上去是 margin,之前应该是触发 margin 合并了

*{padding:0;margin:0;} 试试

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题