换行符<hr />未按预期呈现

时间:2016-05-03 06:25:31

标签: html css

知道为什么我的绿色


上面有一条细灰线,以及如何摆脱它?

由于

https://jsfiddle.net/Lc7gym88/

enter image description here

hr {
  border-bottom: 4px solid #469551;
  width: 30%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0px !important;
  height: 0;
}

4 个答案:

答案 0 :(得分:4)

这是因为<hr/>有边框(至少在FireFox中,因为<hr/>具有浏览器相关的风格)。

首先删除边框。

&#13;
&#13;
hr {
  border: none;
  border-bottom: 4px solid #469551;
  width: 30%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0px !important;
  height: 0;
}
body {
  background-color: black;
}
&#13;
<br/>
<hr/>
&#13;
&#13;
&#13;

答案 1 :(得分:3)

替换它:

border-bottom: 4px solid #469551;

由此:

 border: 4px solid #469551;

Here is the JSFiddle demo

答案 2 :(得分:2)

删除了默认的<hr>边框,并使用了高度和背景

hr {
  background: #469551;
  width: 30%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0px !important;
  height: 4px;
  border:none;
}

示例:https://jsfiddle.net/Lc7gym88/1/

答案 3 :(得分:1)

默认情况下标记<hr>采用边框,因此您需要第一个边框为零。然后添加高度检查我的demo

相关问题