Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added 3d parallax tilty effect on cards #958

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<title>Tourguide</title>
<!-- adding a fav-icon -->
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<link rel="stylesheet" href="tilt.css">
<script src="tilt.js"></script>

<script src="index.js" defer></script>
<script src="mouseEffect.js"></script>
Expand Down Expand Up @@ -531,7 +533,7 @@ <h2 class="section__title">Best trip packages</h2>
Top trip deals curated for you. Get the best package for your adventure and save more.
</p>
<div class="trip__grid">
<div class="trip__card">
<div class="trip__card cardd tilt-effect">
<img src="https://i.ibb.co/60nvYwQ/Screenshot-2023-07-14-173347.png" alt="trip" height="250" width="45" />
<div class="trip__details">
<p>Santorini, Aegean Sea</p>
Expand All @@ -544,7 +546,7 @@ <h2 class="section__title">Best trip packages</h2>
</div>
</div>
</div>
<div class="trip__card">
<div class="trip__card cardd tilt-effect">
<img src="https://i.ibb.co/h1WgH8B/Screenshot-2023-07-14-173807.png" alt="trip" height="250" width="45" />
<div class="trip__details">
<p>Machu Picchu, Peru</p>
Expand All @@ -557,7 +559,7 @@ <h2 class="section__title">Best trip packages</h2>
</div>
</div>
</div>
<div class="trip__card">
<div class="trip__card cardd tilt-effect">
<img src="https://i.ibb.co/vc2W0wN/Screenshot-2023-07-14-174151.png" alt="trip" height="250" width="45" />
<div class="trip__details">
<p>Grand Canyon National Park, Arizona</p>
Expand Down
11 changes: 11 additions & 0 deletions tilt.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.tilt-effect:hover {
transform: rotate3d(1, 1, 0, 20deg); /* Increased angle for more tilt */
transition: transform 0.3s ease, box-shadow 0.3s ease; /* Smooth transition for hover effect and shadow */
box-shadow: 10px 10px 30px rgba(0,0,0,0.5); /* Shadow for depth */
}

.tilt-effect {
transform: rotate3d(1, 1, 0, 0deg); /* Element returns to normal on hover */
box-shadow: 5px 5px 5px rgba(0,0,0,0.5); /* Shadow disappears on hover */
}

8 changes: 8 additions & 0 deletions tilt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$('.cardd').tilt({
maxTilt: 10,
perspective: 1500, // Adjust the perspective if needed
scale: 1.15, // Element scales up slightly on hover
speed: 300, // Speed of the enter/exit transition
transition: true,
});

Loading