简体   繁体   English

为什么 hr 标签底部有额外的空白?

[英]Why there is additional white space at the bottom of the hr tag?

why there is additional white space at the bottom of the hr tag?i wrapped my code with div tag but it has为什么 hr 标签底部有额外的空白?我用 div 标签包装了我的代码,但它有
the white space at the bottom of the hr element. hr 元素底部的空白区域。 i want to remove the white space after the hr element.我想删除 hr 元素后的空白。 在此处输入图像描述

 { text-decoration: none; } body { background-color: #181818; color: white; } h1 { text-align: center; color: #3ea6ff; }.home { font-size: 3em; background-color: white; width: 100%; } #night { color: #f34601; } #mare { color: #3ea6ff; } #left { display: inline-block; width: 100%; background: linear-gradient(to right, #f34601 50%, #3ea6ff 50%); height: 2px; border: 0; }
 <div class="home logo"> <h1 id="mare"> <span id="night">Night</span> mare </h1> <hr id="left"> </div>

Try display:block instead of inline-block .尝试display:block而不是inline-block

 { text-decoration: none; } body { background-color: #181818; color: white; } h1 { text-align: center; color: #3ea6ff; }.home { font-size: 3em; background-color: white; width: 100%; } #night { color: #f34601; } #mare { color: #3ea6ff; } #left { display: block; width: 100%; background: linear-gradient(to right, #f34601 50%, #3ea6ff 50%); height: 2px; border: 0; }
 <div class="home logo"> <h1 id="mare"> <span id="night">Night</span> mare </h1> <hr id="left"> </div>

Or try display:flex或者试试display:flex

 { text-decoration: none; } body { background-color: #181818; color: white; } h1 { text-align: center; color: #3ea6ff; }.home { font-size: 3em; background-color: white; width: 100%; } #night { color: #f34601; } #mare { color: #3ea6ff; } #left { display: flex; width: 100%; background: linear-gradient(to right, #f34601 50%, #3ea6ff 50%); height: 2px; border: 0; }
 <div class="home logo"> <h1 id="mare"> <span id="night">Night</span> mare </h1> <hr id="left"> </div>
Simply removing display will also work as hr is a block element by default. 简单地删除display也将起作用,因为hr默认情况下是一个块元素。

 { text-decoration: none; } body { background-color: #181818; color: white; } h1 { text-align: center; color: #3ea6ff; }.home { font-size: 3em; background-color: white; width: 100%; } #night { color: #f34601; } #mare { color: #3ea6ff; } #left { width: 100%; background: linear-gradient(to right, #f34601 50%, #3ea6ff 50%); height: 2px; border: 0; }
 <div class="home logo"> <h1 id="mare"> <span id="night">Night</span> mare </h1> <hr id="left"> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM