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?

CSSで作る!ゲームボタン設計【CSS】

Posted at

はじめに

本記事では、Webゲームなどインタラクティブな作品で第一印象として大切な、ボタンの見た目や動きの設計についてまとめました。

実際にブラウザゲームで使用しているCSSを例に、

  • 枠線を使わないテキストボタン
  • フォントで「ゲーム感」を出す
  • ホバー時のサイズ変化
  • ボタンごとの役割分担

といった設計の考え方を紹介しています。

1. ゲームUIでは「ボタンらしさ」を消す

一般的なHTMLのボタンは、枠・背景・影がすでに付いている。

#startButton {
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

ポイント

  • デフォルトの装飾をすべて消す
  • 文字そのものをUIとして扱う

これにより、「ゲームらしさ」が増す。

2. position: absolute で「画面基準」に配置する

ゲーム画面では、演出位置も重要になる。

#startButton {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
}

transformを使って真ん中を指定することで、解像度が変わっても同じ位置に配置できる。

3. ホバー演出

#startButton {
  font-size: 45px;
  transition: font-size 0.18s, color 0.18s;
}

#startButton:hover {
  font-size: 53px;
  color: #bbb;
}

影や回転を使わずに文字が前に出てくるような感覚を作る

➡ ゲームを邪魔しない

4. ボタンの重要度で変化をつける

パッと見で重要なボタンが目に付くように、ボタンのデザインも少し変化をつけて工夫すると良い。例えば以下のような感じ。

STARTボタン(最重要)

font-size: 45px;
top: 60%;

SETTINGボタン(補助)

font-size: 35px;
top: 75%;

5. 枠付きボタン

戻るボタンなどはサイズをそこまで大きくしないため、テキストだけだと弱くなりがちである。

#backToTitleButton {
  border: 3px solid #00bcd4;
  border-radius: 24px;
  min-width: 200px;
  min-height: 70px;
}

#backToTitleButton:hover {
  background: linear-gradient(90deg, #b2ebf2, #4dd0e1);
  transform: translate(-50%, 0) scale(1.05);
}

6. モーダル内での「ボタン思想」

モーダル内の×ボタンも同じ考え方で設計を行う。

.close:hover {
  transform: scale(1.2) rotate(8deg);
}

一瞬の動きのみ追加することで、視界を邪魔しすぎない&直感的に分かりやすい×ボタンを実現している。

さいごに

CSSのボタン設計では、「どの程度装飾をつけるか」などの塩梅が難しいです。

本記事の例を参考の一つとして読んでいただければ幸いです。

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?