我想用CSS改变我的hr标签的颜色。我尝试了下面的代码似乎不工作:
hr {
color: #123455;
}
我想用CSS改变我的hr标签的颜色。我尝试了下面的代码似乎不工作:
hr {
color: #123455;
}
当前回答
我在2015年5月的IE, Firefox和Chrome上进行测试,这在当前版本中效果最好。它将HR居中,并使其70%宽:
人力资源。光{ 宽度:70%; 保证金:0汽车; 边框:0px无白色; Border-top:1px纯浅灰色; } <hr class="light" />
其他回答
因为我没有声誉来评论,我将在这里给出一些想法。
如果你想要一个可变高度的CSS,去掉所有的边框,并给出一个背景色。
hr{
height:2px;
border:0px;
background:green;
margin:0px;/*sometimes useful*/
}
/*Doesn't work in ie7 and below and in Quirks Mode*/
if you want simply a style that you know that will work (example: to replace a border in a ::before element for most email clients or hr{ height:0px; border:0px; border-top:2px solid blue; margin:0px;/*useful sometimes*/ } In both ways, if you set a width, it will always have it's size. No need to set display:block; for this. To be totally safe, you can mix both, 'cause some browsers can get confused with height:0px;: hr{ height:1px; border:0px; background:blue; border-top:1px solid blue; margin:0px;/*useful sometimes*/ } With this method you can be sure that it will have at least 2px in height. It's a line more, but safety is safety. This is the method you should use to be compatible with almost everything. Remember: Gmail only detects inline css and some email clients may not support backgrounds or borders. If one fails, you will still have a 1px line. Better than nothing. In the worst cases, you can try to add color:blue;. In the worst of the worst cases, you can try to use a <font color="blue"></font> tag and put your precious <hr/> tag inside it. It will inherit the <font></font> tag color. With this method, you WILL want to do like this: <hr width="50" align="left"/>. Example: <span> awhieugfrafgtgtfhjjygfjyjg <font color="#42B3E5"><hr width="50" align="left"/></font> </span> <!--Doesn't work in ie7 and below and in Quirks Mode--> Here is a link for you to check: http://jsfiddle.net/sna2D/
hr {
background-color: #123455;
}
背景是你应该尝试改变的。
你也可以使用边界的颜色。我不确定;我认为这存在跨浏览器的问题。您应该在不同的浏览器中测试它。
你可以给<hr noshade>标签,然后到你的css文件中添加:
人力资源{ border-top: 0; 颜色:# 123455; } <hr noshade /> 这是个测试 <hr noshade />
你可以使用CSS来创建一条不同颜色的线,示例如下:
border-left: 1px solid rgb(216, 216, 216);
border-right: medium none;
border-width: medium medium medium 2px;
border-style: none none none solid;
border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(216, 216, 216);
该代码将显示垂直的灰线。
你可以这样做:
人力资源{ 边框:1px纯红色; } <人力资源/ > 这是个测试 <人力资源/ >