Skip to content

Instantly share code, notes, and snippets.

@mariohernandez
Last active October 15, 2018 00:45
Embed
What would you like to do?
Example of styles for card component
.movie-card {
background: $color-black;
color: $color-white;
max-width: 460px;
overflow: hidden;
position: relative;
transition: transform 1s ease-in-out;
a {
color: $color-white;
text-decoration: none;
}
// By defalt image overlay is not visible until
// hover is active.
&::after {
background: transparent;
bottom: 0;
content: '';
display: block;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: background 0.25s ease-in-out;
}
&:hover,
&:focus {
transform: scale(1.06);
// Dark overlay.
&::after {
background: rgba($color-black, 0.5);
}
.movie-card__icon {
opacity: 1;
}
// On hover the text content fades into view.
.movie-card__content {
margin-top: 0;
opacity: 1;
}
}
}
.movie-card__heading {
font-weight: 200;
}
.movie-card__rating {
font-weight: 600;
}
.movie-card__cover-image {
img {
display: block;
}
}
// Add to watch list icon.
.movie-card__icon {
align-items: center;
background-color: transparent;
background-image: url('../assets/add-check.svg');
background-repeat: no-repeat;
background-size: 16px 40px;
background-position: 5px 5px;
border: 2px solid rgba($color-white, 0.3);
border-radius: 50%;
display: flex;
height: 30px;
justify-content: center;
opacity: 0;
padding: 5px;
position: absolute;
right: 10px;
top: 10px;
transition: 0.25s ease;
width: 30px;
z-index: 2;
// On hover the icon changes from plus sign to checkmark.
&:hover {
background-position: 5px -21px;
}
// When plus sign icon is clicked button background
// changes to red.
.is-added & {
background-color: #e50914;
background-position: 5px -21px;
}
}
// Text content wrapper.
.movie-card__content {
@include vertical-align(absolute);
font-size: 14px;
font-weight: 300;
left: 20px;
margin-top: 200px;
right: 20px;
transition: margin 0.5s ease 0.125s, opacity 0.5s ease 0.25s;
overflow: hidden;
opacity: 0;
z-index: 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment