0
0

More than 3 years have passed since last update.

よく使うuiパーツ(テキストリンク編)

Last updated at Posted at 2020-10-30
1 / 22

開発においてよく使うuiパーツを残しておこうと思います。
自分はこんな感じで表現していますという程度なので、もしもっと簡単にできるよとか
こんなデザインあるよとかあれば教えてください。


リンクテキスト

よくあるリンクテキストの例を紹介します。


1.矢印付きリンク


スクリーンショット 2020-10-30 9.17.48.png


<a class="c-link" href="#">テキストリンクです。</a>

.c-link {
  display: flex;
  align-items: center;
}

.c-link:before {
  display: inline-block;
  content: "";
  border-top: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 4px solid #ff0000;
}
.c-link:link,
.c-link:visited {
  color: #ff0000;
  text-decoration: none;
}
.c-link:hover {
  text-decoration: underline;
}

2.矢印付きリンク その2


スクリーンショット 2020-10-30 9.29.57.png


<a class="c-link" href="#">テキストリンクです。</a>

.c-link {
  position: relative;
  padding-right: 10px;
}

.c-link:before,
.c-link:after {
  position: absolute;
  right: 0;
  display: inline-block;
  content: "";
  width: 8px;
  height: 8px;
  border-bottom: 1px solid #ff0000;
}
.c-link:before {
  top: calc(50% - 10px);
  transform: rotate(45deg);
}
.c-link:after {
  top: calc(50% - -1px);
  transform: rotate(135deg);
}
.c-link:link,
.c-link:visited {
  color: #ff0000;
  text-decoration: none;
}
.c-link:hover {
  text-decoration: underline;
}

3.矢印付きリンク その3(hoverで矢印の向きをかえる)


通常
スクリーンショット 2020-10-30 9.53.05.png


hover時
スクリーンショット 2020-10-30 9.53.11.png


<a class="c-link" href="#">テキストリンクです。</a>

.c-link {
  position: relative;
  padding-right: 10px;
}

.c-link:before,
.c-link:after {
  position: absolute;
  display: inline-block;
  content: "";
  width: 8px;
  height: 8px;
  border-bottom: 1px solid #ff0000;
  transition: all 0.3s ease-out;
}
.c-link:before {
  top: calc(50% - 4px);
  right: 0;
  transform: rotate(-135deg);
}
.c-link:after {
  top: calc(50% - 4px);
  right: 0;
  transform: rotate(-45deg);
}
.c-link:link,
.c-link:visited {
  color: #ff0000;
  text-decoration: none;
}
.c-link:hover {
  text-decoration: underline;
}
.c-link:hover:before {
  top: calc(50% - 7px);
  transform: rotate(-45deg);
}
.c-link:hover:after {
  top: calc(50% - 7px);
  transform: rotate(45deg);
}

4.フワッと背景テキストリンク


通常時
スクリーンショット 2020-10-30 10.11.26.png


hover時
スクリーンショット 2020-10-30 10.11.31.png


<a class="c-link" href="#">テキストリンクです。</a>

.c-link {
  color: #ff0000;
  transition: all 0.3s ease-out;
}
.c-link:link,
.c-link:visited {
  color: #ff0000;
  text-decoration: none;
}
.c-link:hover {
  color: #fff;
  background: #ff0000;
}

まとめ

テキストリンクは色々デザインがあるので他にもいい実装方法とかデザインがあれば教えてください。

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