29
28

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.

CSSだけでaタグのリンク先プレビューを表示する

Last updated at Posted at 2016-06-25

解説

cssのafter擬似要素にcontentプロパティで値attr(href)を指定し、hover時に表示する感じです。

必要に応じて見た目の装飾をしてあげて下さい。

なお、aタグにはposition: relativeを指定したほうが良いかもしれません。

デモ

コード

html
<a href="http://io.tedokon.com">ここ!</a>
css
a:after {
  position: absolute;
  content: attr(href);
  display: none;
}

a:hover:after {
  display: block;
}
29
28
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
29
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?