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?

More than 5 years have passed since last update.

jQueryにて、架空のキャラ紹介ページをつくってみた(自分用)

Last updated at Posted at 2019-09-19

まえがき

jQuery練習用に作ったシンプルなシステムの1つです。
この場をお借りして投稿させていただきたいと思います。

概要

画面は下図の通りです。
introChara.PNG
各キャラクター名のあたりにカーソルを持ってくると..
introChara2.png
このようにキャラクターの紹介文が表示されます。

コード

CSS


@chaset "UTF-8";

# chara-info ul{
  list-style: none;
  margin: 0;
  padding: 0;
}

.text-contents{
  width: 195px;
  display: none;
}

.chara-role{
  font-size: 30px;
  font-weight: bold;
}

.show-text-content{
  width: 195px;
  display: block;
}

JavaScript

$('.characters').hover(
  function(){
  $(this).find('.text-contents').addClass('show-text-content');
  },
  function(){
    $(this).find('.text-contents').removeClass('show-text-content');
  }
);

解説

hoverメソッドでホバーしているときと終わったときの動作を設定しています。
show-text-contentクラスをつけることで、ホバーしているときにdisplayがnoneからblockへと変わり、紹介文が非表示から表示へと切り換わるようになっています。ホバーが終わった時はその逆をしています。

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?