Set CSS Border Color to text color

后端 未结 3 2042
[愿得一人]
[愿得一人] 2020-12-08 14:52

Is there a way to set the border-color in CSS to be the same as the text color?

For instance having a class which adds a bottom dotted border, but leavi

3条回答
  •  猫巷女王i
    2020-12-08 15:25

    This:

    border-bottom: 1px dotted currentColor;
    

    From the spec:

    currentColor The value of the ‘color’ property. The computed value of the ‘currentColor’ keyword is the computed value of the ‘color’ property. If the ‘currentColor’ keyword is set on the ‘color’ property itself, it is treated as ‘color: inherit’.

    See here: http://www.w3.org/TR/css3-color/#currentcolor

    (doesn't work in IE8 though)


    Update: So, it seems that explicitly setting the color value is not necessary, since the default value already is the value of the color property.

    So, this works just fine:

    border-bottom: 1px solid;
    

提交回复
热议问题