Html 如何定义字段集边框颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3741333/
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:33:06  来源:igfitidea点击:

How can I define fieldset border color?

htmlcssborder

提问by Kali Charan Rajput

I want to set border color of field set. I am using class but this is not working properly because i want to remove fieldset default border color. so how can I use fieldset border color.

我想设置字段集的边框颜色。我正在使用类,但这不能正常工作,因为我想删除字段集默认边框颜色。那么如何使用字段集边框颜色。

<fieldset class="field_set">
    <legend>box</legend>
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
           <tr>
               <td>&nbsp;</td>
           </tr>
      </table>
</fieldset>

css

css

.field_set{
 border-color:#F00;
}

回答by kennytm

It does appear red on Firefox and IE 8. But perhaps you need to change the border-styletoo.

它在 Firefox 和 IE 8 上显示为红色。但也许您也需要更改border-style

.field_set{
  border-color: #F00;
  border-style: solid;
}
<fieldset class="field_set">
  <legend>box</legend>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
</fieldset>

alt text

替代文字

回答by Pekka

It works for me when I define the complete borderproperty. (JSFiddle here)

当我定义完整的border属性时,它对我有用。(JSFiddle在这里

.field_set{
 border: 1px #F00 solid;
}?

the reason is the border-stylethat is set to noneby default for fieldsets. You need to override that as well.

原因是border-style被设置为none默认的字段集。您还需要覆盖它。

回答by user1021860

I added it for all fieldsets with

我为所有字段集添加了它

fieldset {
        border: 1px solid lightgray;
    }

I didnt work if I set it separately using for example

如果我单独设置它,我没有工作,例如

border-color : red

边框颜色:红色

. Then a black line was drawn next to the red line.

. 然后在红线旁边画了一条黑线。

回答by mx0

If you don't want 3D border use:

如果您不想使用 3D 边框,请使用:

border:#f00 1px solid;