Change link color based on href attribute

前端 未结 3 1931
别那么骄傲
别那么骄傲 2021-01-13 18:43

I\'m working on Squarespace for a client that needs to add special blog post that are styled different. The problems is that this template doesn\'t allow it and the client c

3条回答
  •  自闭症患者
    2021-01-13 19:19

    Since you accepted the above answer, here is another way I think it could be better as am not sure appending color like that inside links is a good idea.

    You can rely on CSS variable and do something like this:

    a[href*=special] {
      color: var(--c);
    }
    link 1
    link 2  
    link 2

    Or you can directly apply inline-style:

    Or use data-attribute:

    a[data-color="red"] {
     color:red;
    }
    a[data-color="blue"] {
     color:blue;
    }
    a[data-color="green"] {
     color:green;
    }
    link 1
    link 2  
    link 2

提交回复
热议问题