WEBサイト制作の勉強

WEBサイト制作の勉強の為の解説ブログです。

フェリカテクニカルアカデミー

ホバーにCSS3アニメーション

f:id:yachin29:20160802021335j:plain


transitonによるアニメーション

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>transitonによるアニメーション</title>
<style>
/* reset */
html, body, div, h1, h2, h3, h4, h5, h6,p, blockquote, pre, 
address,ul, ol, li, dl, dt, dd,table, th, td, form, fieldset {
  margin: 0;
  padding: 0;
  line-height: 1.0;
  font-family:
    "Hiragino Kaku Gothic ProN",
    Meiryo, 
    sans-serif;
}
ul {
  list-style: none; /* マーカーを消す */
}
a {
  text-decoration: none; /* 下線を消す */
}
img {
  border: 0;
  vertical-align: bottom;
}
.box {
  width: 500px;
  height:300px;
  background: #06F;
  position:relative;
  overflow: hidden;
}
.cap {
  padding-top: 40%;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  z-index: 10;
  background: rgba(245,44,67,0);
  cursor: default;
  transition: ease 0.3s;
}
.cap:hover {
  top:-40%;/*ホバーした際に動く距離*/
  left: 0;
  background: rgba(245,44,67,1);
}
h3{
  padding-bottom: 20px;
  color: #FFF;
  font-size: 22px;
}
.text { 
  color: #FFF;
  font-size: 16px;
  margin-bottom: 50px;
}
.view {
  width: 40%;
  margin: 0 auto;
  font-size: 20px;
  color: #FFF;
  padding: 10px;
  border: 1px solid #FFF;
  transition: 0.2s ease-in-out;
}
.view:hover{
  background:white;
  color: #111;
  cursor: pointer;
}

</style>
</head>

<body>
<div class="box">
<a href="#">
<div class="cap">
<h3>ページタイトル</h3>
<p class="text">ページの説明文、テキストテキストテキスト</p>
<p class="view">view&nbsp;more</p>
</div>
</a>
</div>
</body>
</html>