<h1>Let's hover!!</h1>
<div class="container">
<div class="card card2">
<figure>
<img class="card__image" src="https://liginc.co.jp/wp-content/uploads/2017/10/150691334095133300_52.png" alt="パソコン">
<figcaption class="card__body">
<h2 class="card__title">Lorem Ipsum</h2>
<p class="card__text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<time class="card__date" datetime="2011-12-03">2011.12.03</time>
</figcaption>
</figure>
</div>
</div>
$color: #4cc48e;
$font-main: 'Hammersmith One', sans-serif;
$font-sub: 'Open Sans';
* {
box-sizing: border-box;
}
body {
font-family: $font-sub;
background: #b7b7b7;
}
h1 {
font-family: 'Hammersmith One','Helvetica Neue','Helvetica','Arial',YuGothic,'Yu Gothic',sans-serif;
text-align: center;
font-size: 2rem;
margin-top: 20px;
}
.container {
max-width: 1150px;
margin: 20px auto;
display: flex;
flex-wrap: wrap;
}
.card {
margin: auto;
width: 350px;
cursor: pointer;
background-color: #fff;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1), 0 8px 20px rgba(0, 0, 0, 0.1);
&:nth-child(2n) {
margin: 0 30px;
}
}
.card__body {
padding: 20px;
}
.card__title {
font-size: 1.7rem;
line-height: 1.5;
font-family: $font-main;
}
.card__text {
line-height: 1.3;
margin-bottom: 8px;
}
.card__image {
width: 100%;
height: 200px;
object-fit: cover;
border-bottom: 1px solid gray;
}
.card__date {
color: gray;
font-size: 0.8rem;
}
/* card hover animation 2 */
.card2 {
position: relative;
.card__title {
color: #d0542e;
}
&::before {
position: absolute;
width: 100%;
height: 200px;
display: block;
content: '';
background-color: black;
opacity: 0;
z-index: 1;
transition: all 0.5s;
}
&::after {
content: 'READ MORE';
font-family: $font-main;
display: block;
position: absolute;
top: 95px;
width: 100%;
text-align: center;
font-size: 1.3rem;
transition: all 0.5s;
color: #fff;
z-index: 2;
opacity: 0;
}
figure {
position: relative;
overflow: hidden;
&::before {
position: absolute;
content: '';
background-color: #d0542e;
top: 185px;
width: 100%;
height: 15px;
z-index: 3;
display: block;
transform: translate(-100%,0);
transition: all 0.5s;
}
}
&:hover {
&::before {
opacity: 0.6;
}
&::after {
opacity: 1;
}
figure {
&::before {
transform: translate(0,0);
}
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.