我可以增加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;
- }
解决方法
你已经成功了. hr没有上边距或下边距.它是显示填充和/或边距的p元素.在这里你可以看到这个:
- 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>