- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>On-hover effects: buttons, part 2</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>
</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-green {
background-color: #1abc9c;
border-bottom: 2px solid #12ab8d;
box-shadow: inset 0 -2px #12ab8d;
}
.btn-yellow {
background-color: #f1c40f;
border-bottom: 2px solid #e2b607;
box-shadow: inset 0 -2px #e2b607;
}
.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;
transition: opacity 0.2s ease-in-out;
}
.btn-yellow:hover .icon {
}
You’ve gone to a different page
Goalscompleted
0
- For
.btn-yellow:hover .hidden
, setopacity
to be equal to1
. - For
.btn-yellow:hover .icon
set thescale
transform to the value10
. - And also set
opacity
to0
.
After you complete every change, hover the cursor over the yellow button to check your work.
Comments