Html 为什么 <hr /> 的颜色没有变化?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3764571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:34:53  来源:igfitidea点击:

Why doesn't <hr />'s colour change?

htmlcss

提问by Skizit

I've got the following...

我有以下...

 <hr style="color:#292929;background-color:#292929;"/>

but the colour isn't changing to the HTML colour code I've declared. Why not?

但颜色不会更改为我声明的 HTML 颜色代码。为什么不?

回答by Jon B

Set border-color.

设置border-color

回答by ford

the hr tag is a bit tricky vs other elements to style. Which things work and which ones don't is very browser dependent.

与其他元素相比,hr 标签有点棘手。哪些有效,哪些无效取决于浏览器。

A cache of tricks (including coloration) is available here: http://webdesign.about.com/od/beginningcss/a/style_hr_tag.htm

技巧缓存(包括着色)可在此处获得:http: //webdesign.about.com/od/beginningcss/a/style_hr_tag.htm

回答by Gilly

  1. Try giving it a height like 5px;
  2. Give it your border styles but with 0px width.
  3. Re-apply a 1px width to either top or bottom:
  1. 尝试给它一个像 5px 这样的高度;
  2. 给它你的边框样式,但宽度为 0px。
  3. 将 1px 的宽度重新应用到顶部或底部:

Result:

结果:

<hr style="height: 5px; border: 0px solid #D6D6D6; border-top-width: 1px;" />

回答by Sagiv Ofek

instead of: color:#292929;

代替: color:#292929;

use: border-color:#292929;

用: border-color:#292929;

回答by den_ban

just use a ptag with border, above unswers give no result for me...

只需使用p带边框的标签,上面的 unswers 不会给我任何结果......

<p style="border-bottom: 1px solid #D6D6D6; padding-bottom: 20px; margin-bottom: 20px"></p>

<p style="border-bottom: 1px solid #D6D6D6; padding-bottom: 20px; margin-bottom: 20px"></p>

回答by Dave Hogan

Try styling the border instead

尝试设置边框样式

回答by Matt Nathanson

try defining a height

尝试定义高度

回答by Jason Wolfram

Sagivo, Bless you and thank you. That did the trick after a good hour+ of messing with the problem. FYI to others I found that to get a similar look in both Outlook(the evil one) and other web clients including older IE I used this.

Sagivo,祝福你,谢谢你。经过一个小时以上的问题处理后,这确实奏效了。仅供参考,我发现为了在 Outlook(邪恶的)和其他 Web 客户端(包括旧版 IE)中获得类似的外观,我使用了它。

<hr size="2" width="80%" align="center" style="border-color:#878787; background:#878787">

Setting size to 1 made it too thick in some places, and 2 with out the background color too thin in others. This is what I ended up with. Hope it helps someone else.

将 size 设置为 1 会使某些地方太厚,而将 2 设置为 2 会使其他地方的背景颜色太薄。这就是我的结果。希望它可以帮助别人。