Step 4: Add CSS
Copy the CSS (styles) below into the CSS file. This will add our shine effect.
.shine {
width: 100%;
min-height:300px;
position:absolute;
top:0px;
left: 0;
overflow: hidden;
display: inline-block;
}
.shine img {
width:100%;
height:100%;
}
/* Overlay over image that does the shine */
.shine:after {
content: "";
position: absolute;
top: -50%;
left: -60%;
width: 20%;
height: 200%;
opacity: 0;
transform: rotate(30deg);
overflow:hidden;
background: rgba(255, 255, 255, 0.13);
background: linear-gradient(
to right,
rgba(255, 255, 255, 0.13) 0%,
rgba(255, 255, 255, 0.13) 77%,
rgba(255, 255, 255, 0.5) 92%,
rgba(255, 255, 255, 0.0) 100%
);
}
/* Hover state - trigger effect */
.shine:hover:after {
opacity: 1;
left: 130%;
transition-property: left, top, opacity;
transition-duration: 0.7s, 0.7s, 0.15s;
transition-timing-function: ease-out;
}
/* Active state */
.shine:active:after {
opacity: 0;
}
If you've done everything correctly, you should be able to preview and get the same effect that you get when you over the image below.
Step 6: Add Reverse Feature
Let's add a design input this time to reverse the input and then update the HTML & CSS used to support the right or left shine.
//new HTML
//new CSS
.shine {
width: 100%;
min-height:300px;
position:absolute;
top:0px;
left: 0;
overflow: hidden;
display: inline-block;
z-index:5;
}
.shine img {
width:100%;
height:100%;
}
/* Overlay over image that does the shine */
.shine:after {
content: "";
position: absolute;
top: -50%;
width: 20%;
height: 200%;
opacity: 0;
transform: rotate(30deg);
overflow:hidden;
background: rgba(255, 255, 255, 0.13);
background: linear-gradient(
to right,
rgba(255, 255, 255, 0.13) 0%,
rgba(255, 255, 255, 0.13) 77%,
rgba(255, 255, 255, 0.5) 92%,
rgba(255, 255, 255, 0.0) 100%
);
}
.left:after{
left: -60%;
}
.right:after {
right: -60%;
}
/* Hover state - trigger effect */
.left:hover:after {
opacity: 1;
left: 130%;
transition-property: left, top, opacity;
transition-duration: 0.7s, 0.7s, 0.15s;
transition-timing-function: ease-out;
}
.right:hover:after {
opacity: 1;
right: 130%;
transition-property: right, top, opacity;
transition-duration: 0.7s, 0.7s, 0.15s;
transition-timing-function: ease-out;
}
/* Active state */
.shine:active:after {
opacity: 0;
}
Now we'll be able to reverse the direction of the shine effect.