CSS 属性边框颜色不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14156674/
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
CSS Property Border-Color Not Working
提问by Zeb-ur-Rehman
I have issue with border-color. It didn't work. I'm new to css here is the fiddle. http://jsfiddle.net/zeburrehman/aFzKy/151/
我有边框颜色的问题。它没有用。我是 css 新手,这里是小提琴。 http://jsfiddle.net/zeburrehman/aFzKy/151/
<div id="box">
Hello! The color of box border should be red!!
</div>?
#box {
border-color: red;
}?
回答by Ashwin
By default the border-width
is 0
and border-style
is none
默认情况下border-width
是0
和border-style
是none
So you need to set them to border-width:1px
and border-style:solid
. You can combine all the border properties into one as below:
所以你需要将它们设置为border-width:1px
和border-style:solid
。您可以将所有边框属性合并为一个,如下所示:
#box {
border:1px solid red
}
回答by Shaun
I had an issue where it seemed that border-color
was not being respected, confusingly it even showed having the right color in the style inspector in Chrome (possibly a Chrome bug). The key thing for me was that if the shorthand border style is specified, it sets all three aspects of the border style, regardless of if they are included or not so:
我有一个问题,似乎border-color
没有得到尊重,令人困惑的是,它甚至在 Chrome 的样式检查器中显示了正确的颜色(可能是 Chrome 错误)。对我来说,关键是如果指定了速记边框样式,它会设置边框样式的所有三个方面,无论是否包含它们:
border-left: 1px;
Actually overwrites both the border-left-style
and border-left-color
properties even though they weren't included. This can for example cause an inherited style to be overridden and appear not to work.
实际上覆盖了border-left-style
和border-left-color
属性,即使它们没有被包含在内。例如,这可能导致继承的样式被覆盖并且看起来不起作用。
回答by RJo
You need to add the border style:
您需要添加边框样式:
#box {
border: 1px solid red;
}
回答by Tanky
Try this : border: 5px solid red;
试试这个:边框:5px纯红色;
回答by Hunter
You can use hex color code for red as well, which is #ff0000
(RGB). 100% Red, 0% Green and 0% Blue if you want pure red color.
您也可以将十六进制颜色代码用于红色,即#ff0000
(RGB)。如果您想要纯红色,则为 100% 红色、0% 绿色和 0% 蓝色。
#box {
border: 2px solid #ff0000;
}
回答by IsMaTh IM
#box{
border:3px solid #aacfac;
}
I hope this helps!
我希望这有帮助!