html - 如何减少hr标签的默认边距?

标签 html css

我可以增加 hr 标签的默认边距。但是我不能将 hr 的边距减少到零。我所需要的只是顶部和底部边距为零的水平线

<p>This is header</p>
<hr class="divider" />
<p>This is content. I just want to reduce the margin of hr tag</p>
hr.divider
{ 
   margin-top: 0em;
   margin-bottom: 0em;
   border-width: 2px;
} 

另见 this jsfiddle .

最佳答案

您已经成功了。 hr 没有顶部或底部边距。 p 元素显示了 padding 和/或 margin。在这里您可以看到实际效果:

 hr.divider { 
  margin: 0em;
  border-width: 2px;
} 

p {
  margin: 0;
  padding: 0; 
}
<p>This is header</p>
<hr class="divider" />
<p>This is content. I just want to reduce the margin of hr tag to zero</p>

关于html - 如何减少hr标签的默认边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31241917/

相关文章:

html - 全屏背景,固定位置在正文上方和内容下方

html - 无法使标题居中

PHP/SQLite 接受不正确的发布值

css - 启用 UseStaticHeaders 时 Telerik Radgrid Group Header 对齐问题

html - 用于从此 HTML 中提取地址的 XPath 表达式

html - 移动网站 : Detecting when images have been disabled

php - 如何使图标在左侧对齐的中心图标列表小部件(Elementor)?

css - Laravel 3 分页未使用 Bootstrap 3 正确格式化

javascript - 使用 CSS 在 HTML 中模糊 Img 和 Div

javascript - 全屏 YouTube 视频作为背景,没有分享/稍后观看/图标/开始按钮