0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Stylishの設定が反映されない(Linkを訪問済みの場合は色を変えたいのに変わらない問題)

Last updated at Posted at 2021-07-16

通常はCSSをサイト外から直接触る拡張機能
stylish(CSSを拡張機能から触るものなら何でもok。)
これらを使えば問題なく動きます。
でもサイトによってはstylishの設定が反映されない場合があります。

悩み

stylishを設定しても反映されない。


stylishでこのように設定してみます。

a:visited {
    color: #00FF00;
}

しかしリロードしても反映されませんでした。
この問題を解決します。

理由

例えば、

<a style="color: #0000FF;" href="https://www.google.com/">google</a>

このように直接タグに色を指定していると、CSSの優先順位によってstylishの設定が反映されません。

解決策

a:visited {
    color: #00FF00 !important;
}

!importantを設定して強制的に反映させます。

CSSはより細かく指定するほうが優先されるからです。通常サイト制作時にこの!importantを使うのは禁じ手ですが、今回のような場合には有用です。
CSSの優先順位のルールは各自調べてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?