2019/03/12
css
備忘録です。
リンクhover時に下線が右から左に動いたり中央から左右に伸びるアレの方法です。
参考サイト
リンク要素のhover時に下線をCSSでアニメーション表示させる方法
html
<ul> <li><a href="">MENU01</a></li> <li><a href="">MENU02</a></li> <li><a href="">MENU03</a></li> <li><a href="">MENU04</a></li> <li><a href="">MENU05</a></li> </ul>
下線が左から右に引かれるアニメーション
ul {
  display: flex;
  list-style: none;
}
li {
  padding: 5px;
}
a {
  display: block;
  padding: 0 0 5px;
  text-decoration: none;
}
a::after {
  border-bottom: solid 2px #f00;
  bottom: 0;
  content: "";
  display: block;
  transition: all .3s ease;
  -webkit-transition: all .3s ease;
  width: 0;
}
a:hover::after {
  width: 100%;
}
下線が右から左に引かれるアニメーション
ul {
  display: flex;
  list-style: none;
}
li {
  padding: 5px;
}
a {
  display: block;
  padding: 0 0 5px;
  position: relative;
  text-decoration: none;
}
a::after {
  border-bottom: solid 2px #f00;
  bottom: 0;
  content: "";
  display: block;
  position: absolute;
  right: 0;
  transition: all .3s ease;
  -webkit-transition: all .3s ease;
  width: 0;
}
a:hover::after {
  width: 100%;
}
下線が中央から左右に引かれるアニメーション
ul {
  display: flex;
  list-style: none;
}
li {
  padding: 5px;
}
a {
  display: block;
  padding: 0 0 5px;
  position: relative;
  text-decoration: none;
}
a::before,
a::after {
  border-bottom: solid 2px #f00;
  bottom: 0;
  content: "";
  display: block;
  position: absolute;
  transition: all .3s ease;
  -webkit-transition: all .3s ease;
  width: 0;
}
a::before {
  left: 50%;
}
a::after {
  right: 50%;
}
a:hover::before,
a:hover::after {
  width: 50%;
}
                        ゼヒトモ内でのプロフィール: ROCKSTREAM, ゼヒトモのホームページ作成・制作サービス, 仕事をお願いしたい依頼者と様々な「プロ」をつなぐサービス
2025/01/31
JQuery
2025/01/01
神社
御朱印
相模原
2024/10/27
ブラウザ
カスタム投稿
Wordpress
2024/08/20
神社
御朱印
2024/07/06
神社
御朱印
