LoginSignup
13

More than 5 years have passed since last update.

マウスホバー時に画像を表示する

Posted at

sampleGif2.gif

html


<a href="#">ねこさん</a>

CSS


a{
  position: relative;
}

a:after{
  content: "";
  position: absolute;
  top: 1em;
  left: 0;
  display: inline-block;
  pointer-events: none;
  width: 300px;
  height: 300px;
}

a:hover:after{
  background: url(nekosan.JPG); /* 表示する画像 */
  background-size: contain; 
  background-repeat: no-repeat;
  background-position: center top;
}

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
13