Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Last active April 6, 2023 01:32
Show Gist options
  • Select an option

  • Save mfrancois3k/3aaf31333de294ef01a47eee62d1f534 to your computer and use it in GitHub Desktop.

Select an option

Save mfrancois3k/3aaf31333de294ef01a47eee62d1f534 to your computer and use it in GitHub Desktop.
Card Hover Effect Overlay CSS awwards #CSS #effects #awwwards
refence from this tutorial
https://www.youtube.com/watch?v=-ISvtF4wUrs&loop=0
// concept
-----------------------
<div class="container"> <!-- Main container -->
<div class="nav"> <!-- Navigation bar -->
<div class="nav-item">logo</div>
<div class="nav-item">art gallery</div>
<div class="nav-item">menu</div>
</div>
<div class="items"> <!-- Items container -->
<!-- Repeated structure for each item -->
<div class="item">
<div class="item-wrapper">
<img src="https://source.unsplash.com/400x1000/?3dmodel" width="" height="" style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt="">
<div class="img-overlay"></div> <!-- Overlay for hover effect -->
<div class="item-copy"> <!-- Item content -->
<div class="item-name">
THE FEMININE ENERGY <span>mdxclii</span>
</div>
<div class="id">1</div>
</div>
</div>
</div>
<!-- Add more items here -->
</div>
</div>
copy below
-----------------------
<div class="container">
<div class="nav">
<div class="nav-item">logo</div>
<div class="nav-item">art gallery</div>
<div class="nav-item">menu</div>
</div>
<div class="items">
<div class="item">
<div class="item-wrapper">
<img src="https://source.unsplash.com/400x1000/?3dmodel" width="" height=""
style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt="">
<div class="img-overlay"></div>
<div class="item-copy">
<div class="item-name">
THE FEMININE ENERGY <span>mdxclii</span>
</div>
<div class="id">1</div>
<!-- <img src="https://source.unsplash.com/400x1000/?Painting " width="" height="" style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt=""> -->
</div>
</div>
</div>
<div class="divider"></div>
<div class="divider"></div>
<div class="item">
<div class="item-wrapper">
<img src="https://source.unsplash.com/400x1000/?artist " width="" height=""
style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt="">
<div class="img-overlay"></div>
<div class="item-copy">
<div class="item-name">
THE artist in studio <span>mdxclii</span>
</div>
<div class="id">2</div>
</div>
</div>
</div>
<div class="divider"></div>
<div class="item">
<div class="item-wrapper">
<img src="https://source.unsplash.com/400x1000/?landscape " width="" height=""
style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt="">
<div class="img-overlay"></div>
<div class="item-copy">
<div class="item-name">
titan warrior as monk <span>mdxclii</span>
</div>
<div class="id">3</div>
</div>
</div>
</div>
<div class="divider"></div>
<div class="item">
<div class="item-wrapper">
<img src="https://source.unsplash.com/400x1000/?warrior " width="" height=""
style="margin:0; padding:0; border:none; display:block;" border="0" class="img" alt="">
<div class="img-overlay"></div>
<div class="item-copy">
<div class="item-name">
titan warrior as monk <span>mdxclii</span>
</div>
<div class="id">4</div>
</div>
</div>
</div>
<div class="divider"></div>
</div>
</div>
</div>
<div class="divider"></div>
</div>
</div>
</div>
</div>
<div class="divider"></div>
<script type="module" src="/main.js"></script>
</body>
</html>
// Import necessary files
@import './src/foundation/layouts/index.scss';
// Global settings
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
// Main container
.container {
width: 100%;
height: 100vh;
overflow: hidden;
}
// Navigation bar
.nav {
position: fixed;
width: 100%;
padding: 1em;
display: flex;
justify-content: space-between;
align-items: center;
font-family: "Neue Montreal";
text-transform: uppercase;
color: #fff;
mix-blend-mode: difference;
z-index: 3;
}
// Items container
.items {
width: 100%;
height: 100%;
display: flex;
}
// Divider between items
.divider {
position: relative;
width: 1px;
height: 100vh;
background: rgba(0, 0, 0, 0.25);
}
// Item structure
.item {
position: relative;
width: 25vw;
height: 100vh;
overflow: hidden;
}
// Image overlay for hover effect
.img-overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: #dfdbd5;
transition: 1s cubic-bezier(0.075, 0.82, 0.165, 1);
}
.item-wrapper:hover .img-overlay {
top: -100%;
}
// Image settings
.item img {
position: absolute;
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1.5);
transition: 2s cubic-bezier(0.075, 0.82, 0.165, 1);
}
.item-wrapper:hover img {
transform: scale(1);
}
// Item content
.item-copy {
position: absolute;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 8em 2em;
text-transform: uppercase;
line-height: 60px;
color: #000;
z-index: 2;
transition: 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
}
// Item name settings
.item-name {
font-size: 40px;
span {
font-family: serif;
font-size: 20px;
line-height: 120%;
text-transform: uppercase;
display: block;
}
}
// Item ID settings
.item-copy .id {
color: red;
font-size: 150px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment