目录

border-color

描述 (Description)

border-color属性允许您更改元素周围边框的颜色。 您可以使用属性单独更改元素边框的底部,左侧,顶部和右侧的颜色 -

  • border-bottom-color更改底部边框的颜色。

  • border-top-color更改顶部边框的颜色。

  • border-left-color更改左边框的颜色。

  • border-right-color更改右边框的颜色。

可能的值 (Possible Values)

  • color - 任何有效的颜色值。

  • transparent - 将边框设置为不可见。

适用于 (Applies to)

所有HTML元素。

DOM语法 (DOM Syntax)

object.style.borderColor = "red";

例子 (Example)

以下示例显示了所有这些属性的效果 -

<html>
   <head>
      <style type = "text/css">
         p.example1 {
            border:1px solid;
            border-bottom-color:#009900; /* Green */
            border-top-color:#FF0000;    /* Red */
            border-left-color:#330000;   /* Black */
            border-right-color:#0000CC;  /* Blue */
         }
         p.example2 {
            border:1px solid;
            border-color:#009900;        /* Green */
         }
      </style>
   </head>
   <body>
      <p class = "example1">
         This example is showing all borders in different colors.
      </p>
      <p class = "example2">
         This example is showing all borders in green color only.
      </p>
   </body>
</html> 

这将产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018