- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>On-hover effects: buttons, part 3</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="buttons">
<button class="btn-green" type="button">
<img class="icon" src="icons/reload-6x-white.png" alt="Reloading the icon"> Refresh
</button>
<button class="btn-yellow" type="button">
<span class="hidden">25<img src="icons/dollar-6x-white.png" alt="Dollar icon"></span>
<img class="icon" src="icons/cart-6x-white.png" alt="Cart icon"> Buy
</button>
<button class="btn-blue" type="button">
<span class="hidden"><img src="icons/envelope-open-6x-white.png" alt="Open envelope icon"></span>
<img class="icon" src="icons/envelope-closed-6x-white.png" alt="Closed envelope icon"> Read
</button>
</div>
</body>
</html>
CSS
body {
margin: 0;
padding: 0;
font-family: "Arial Narrow", "Arial", sans-serif;
background-color: #f5f5f5;
}
.buttons {
width: 400px;
margin: 50px auto;
padding: 10px 20px;
text-align: center;
background-color: white;
box-shadow: 0 0 3px #cccccc;
}
button {
position: relative;
width: 300px;
height: 60px;
margin: 20px auto;
padding: 0;
font-size: 22px;
text-align: center;
color: white;
border: none;
outline: none;
cursor: pointer;
overflow: hidden;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
transition: transform 0.4s ease-in-out;
}
button:active {
top: 1px;
box-shadow: none;
}
.icon {
position: absolute;
left: 20px;
}
.hidden {
position: absolute;
opacity: 0;
}
.hidden img {
width: 24px;
height: 24px;
margin-left: 5px;
vertical-align: top;
}
.btn-yellow {
background-color: #f1c40f;
border-bottom: 2px solid #e2b607;
box-shadow: inset 0 -2px #e2b607;
}
.btn-green {
background-color: #1abc9c;
border-bottom: 2px solid #12ab8d;
box-shadow: inset 0 -2px #12ab8d;
}
.btn-blue {
background-color: #2980b9;
border-bottom: 2px solid #2475ab;
box-shadow: inset 0 -2px #2475ab;
}
.btn-green .icon {
width: 24px;
height: 24px;
transition: all 0.4s ease-in-out;
}
.btn-green:hover .icon {
transform: rotate(360deg) scale(1.2);
}
.btn-yellow .icon {
width: 32px;
height: 32px;
transition: all 0.4s ease-in-out;
}
.btn-yellow:hover .hidden {
left: 20px;
opacity: 1;
transition: opacity 0.2s ease-in-out;
}
.btn-yellow:hover .icon {
transform: scale(10);
opacity: 0;
}
.btn-blue .icon {
width: 28px;
height: 28px;
transition: all 0.2s ease-in-out;
}
.btn-blue .hidden {
left: 15px;
top: 12px;
opacity: 0;
}
.btn-blue .hidden img {
width: 28px;
height: 28px;
}
.btn-blue:hover .hidden {
transition:
opacity 0.2s ease-in-out,
transform 0.2s ease-in-out 0.1s;
}
.btn-blue:hover .icon {
}
You’ve gone to a different page
Goalscompleted
0
- For
.btn-blue:hover .icon
, setopacity
to0
. - For
.btn-blue:hover .hidden
, set thescale
transform to the value1
and theopacity
to1
. - For
.btn-blue .hidden
, set thescale
transform to the value0
.
After you complete every change, hover the cursor over the blue button to check your work.
Comments