CSS - Add Color with a data attribute - attr(data-color color)

前端 未结 6 1122
[愿得一人]
[愿得一人] 2020-12-14 08:16

I\'m trying to add color to different element with a data attribute in my css but doensn\'t work ...

I follow this instructions :

The attr() Function: Proper

6条回答
  •  春和景丽
    2020-12-14 08:52

    You can pass css values from html:

    
    

    to css:

    button::after {
      content: var(--tooltip-string);
      color: var(--tooltip-color);
      font-size: var(--tooltip-font-size);
    }
    

    source: https://css-tricks.com/css-attr-function-got-nothin-custom-properties/ codepen: https://codepen.io/chriscoyier/pen/EbxVME

提交回复
热议问题