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 5 years have passed since last update.

Sassのhoverとactiveは&記号で楽に使える

Posted at

sassのhover

カーソルが乗ったときにのみ色を変えたりできる状態です。
CSSの場合は、セレクタ:hoverで、
Sassの場合は、&:hoverで実行できます。
【例】

stylesheet.scss
.main {
  font-size: 20px;
  text-align: center;
  &:hover {
    opacity: 1;
  }
}

Sassのactive

要素(ボタンなど)がクリックされている間だけCSSを適用します。
こちらもhoverと一緒でCSSの場合は、セレクタ:activeで、
Sassの場合は、&:activeで実行できます。
【例】

stylesheet.scss
.main {
  font-size: 20px;
  text-align: center;
  &:active {
    position: relative;
    top: 5px;
    box-shadow: none;
  } 
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?