Skip to content

Instantly share code, notes, and snippets.

View smlparry's full-sized avatar
🔥

Samuel Parry smlparry

🔥
View GitHub Profile
<div class="parallax-container">
<div class="background">
<img class="background__image" src="https://path/to/image.jpg" />
</div>
<div class="foreground">
<div class="foreground__content">
<h1>Oooo, parallax</h1>
</div>
</div>
</div>
.parallax-container {
position: relative;
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
perspective: 8px;
perspective-origin: 0%;
display: flex;
}
.element {
// ...
transform: translateZ(0px);
animation: animateZ 2s infinite;
}
@keyframes animateZ {
from {
transform: translateZ(0px);
}
@smlparry
smlparry / css-parallax-1.css
Last active June 24, 2019 13:05
css-parallax-1
# CSS
.container {
display: flex;
justify-content: center;
align-items: center;
border: 1px solid black;
height: 200px;
width: 200px;
perspective: 8px;
perspective-origin: 50%;
$(document).ready(function() {
var $grid = $('.grid')
var $gridItem = $('.grid__item')
var gridItemHeight = $gridItem.height()
var gridItemWidth = $gridItem.width()
var horzCount = Math.floor($grid.width() / gridItemWidth)
var vertCount = Math.floor($grid.height() / gridItemHeight)
/* ... */
.grid__item {
/* ... */
transition: opacity 2s ease 0.4s, transform 0.8s ease;
transform: scale(1);
}
.grid__item:hover {
/* ... */
.grid__item {
/* ... */
opacity: 0;
transition: opacity 0.4s ease;
}
.grid__item:hover {
.grid {
display: flex;
flex-wrap: wrap;
width: 500px;
height: 400px;
}
.grid__item {
height: 60px;
width: 60px;
.grid
- 56.times do
.grid__item
<template>
<!-- HTML Emitted -->
</template>
<script>
// ...
export default {
// ...