initial commit
This commit is contained in:
53
JS/script.js
Normal file
53
JS/script.js
Normal file
@ -0,0 +1,53 @@
|
||||
const cards = document.querySelectorAll(".card");
|
||||
|
||||
cards.forEach(el => {
|
||||
// Variable pour suivre si la souris est sur la carte
|
||||
let isHovered = false;
|
||||
|
||||
// Événement lorsque la souris entre dans la carte
|
||||
el.addEventListener("mouseenter", () => {
|
||||
|
||||
// La souris est sur la carte
|
||||
isHovered = true;
|
||||
});
|
||||
|
||||
// Événement lorsque la souris bouge à l'intérieur de la carte
|
||||
el.addEventListener("mousemove", e => {
|
||||
if (isHovered) {
|
||||
|
||||
// Récupérer les dimensions et la position de la carte
|
||||
let elRect = el.getBoundingClientRect();
|
||||
|
||||
// Calculer la position de la souris relative à la carte
|
||||
let x = e.clientX - elRect.x;
|
||||
let y = e.clientY - elRect.y;
|
||||
|
||||
// Calculer les angles de rotation en fonction de la position de la souris
|
||||
let midCardWidth = elRect.width / 2;
|
||||
let midCardHeight = elRect.height / 2;
|
||||
let angleY = -(x - midCardWidth) / 8;
|
||||
let angleX = (y - midCardHeight) / 8;
|
||||
|
||||
// Calculer les coordonnées du dégradé radial en fonction de la position de la souris
|
||||
let glowX = (x / elRect.width) * 100;
|
||||
let glowY = (y / elRect.height) * 100;
|
||||
|
||||
// Appliquer les transformations CSS à l'élément enfant numéro 0 et 1 de la carte
|
||||
el.children[0].style.transform = `rotateX(${angleX}deg) rotateY(${angleY}deg) scale(1.1)`;
|
||||
el.children[1].style.transform = `rotateX(${angleX}deg) rotateY(${angleY}deg) scale(1.1)`;
|
||||
// Appliquer le dégradé radial au fond d'arrière-plan de l'élément enfant numéro 1 de la carte
|
||||
el.children[1].style.background = `radial-gradient(circle at ${glowX}% ${glowY}%, rgb(184, 196, 211), transparent)`;
|
||||
}
|
||||
});
|
||||
|
||||
// Événement lorsque la souris quitte la carte
|
||||
el.addEventListener("mouseleave", () => {
|
||||
// La souris n'est plus sur la carte
|
||||
isHovered = false;
|
||||
// Réinitialiser les transformations CSS des éléments enfants de la carte
|
||||
el.children[0].style.transform = "rotateX(0) rotateY(0)";
|
||||
el.children[1].style.transform = "rotateX(0) rotateY(0)";
|
||||
// Réinitialiser le fond d'arrière-plan de l'élément enfant numéro 1 de la carte
|
||||
el.children[1].style.background = "";
|
||||
});
|
||||
});
|
22
Pages/Card Football.html
Normal file
22
Pages/Card Football.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=*, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../css/Card football.css">
|
||||
<title>Card Effect Football</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="content-card"><img src="../img/Perrin.png" alt="">
|
||||
</div>
|
||||
<div class="glow"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../JS/script.js"></script>
|
||||
</body>
|
||||
</html>
|
24
Pages/Card Pokemon.html
Normal file
24
Pages/Card Pokemon.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=*, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../css/Card Pokemon.css">
|
||||
<link rel="icon" href="img/Palkia.ico" type="image/x-icon">
|
||||
|
||||
<title>Card Effect Pokémon</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="content-card"><img src="../img/Carte.png" alt="">
|
||||
</div>
|
||||
<div class="glow"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../JS/script.js"></script>
|
||||
</body>
|
||||
</html>
|
44
css/Card Pokemon.css
Normal file
44
css/Card Pokemon.css
Normal file
@ -0,0 +1,44 @@
|
||||
*,
|
||||
::before
|
||||
::after{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body{
|
||||
background-image: url("../img/background_pokemon.jpg");
|
||||
background-color: red;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card{
|
||||
width: 350px;
|
||||
height: 500px;
|
||||
perspective: 1000px;
|
||||
|
||||
}
|
||||
|
||||
.content-card{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
border-radius: 25px;
|
||||
transition: all 0.25s ease-out;
|
||||
}
|
||||
|
||||
.glow{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: all 0.25s ease-out;
|
||||
border-radius: 25px;
|
||||
mix-blend-mode: hard-light;
|
||||
background: radial-gradient(circle at 50% 0%, rgba(31, 34, 37, 0.014), transparent );
|
||||
}
|
44
css/Card football.css
Normal file
44
css/Card football.css
Normal file
@ -0,0 +1,44 @@
|
||||
*,
|
||||
::before
|
||||
::after{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body{
|
||||
background-image: url('../img/background.jpg');
|
||||
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card{
|
||||
width: 350px;
|
||||
height: 500px;
|
||||
perspective: 1000px;
|
||||
|
||||
}
|
||||
|
||||
.content-card{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
border-radius: 25px;
|
||||
transition: all 0.25s ease-out;
|
||||
}
|
||||
|
||||
.glow{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: all 0.25s ease-out;
|
||||
border-radius: 25px;
|
||||
mix-blend-mode: hard-light;
|
||||
background: radial-gradient(circle at 50% 0%, rgba(31, 34, 37, 0.014), transparent );
|
||||
}
|
44
css/style.css
Normal file
44
css/style.css
Normal file
@ -0,0 +1,44 @@
|
||||
*,
|
||||
::before
|
||||
::after{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 300px;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.image{
|
||||
height: 250px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.img{
|
||||
height: 269px;
|
||||
width: 219px;
|
||||
}
|
||||
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
BIN
img/Carte.png
Normal file
BIN
img/Carte.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 365 KiB |
BIN
img/Palkia.ico
Normal file
BIN
img/Palkia.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
BIN
img/Perrin.png
Normal file
BIN
img/Perrin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 422 KiB |
BIN
img/background.jpg
Normal file
BIN
img/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 842 KiB |
BIN
img/background_pokemon.jpg
Normal file
BIN
img/background_pokemon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
32
index.html
Normal file
32
index.html
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<title>Card Effect</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<h2>Card 1</h2>
|
||||
<p>Card with 3D effect of the footballer Loic Perrin</p>
|
||||
<img class="image" src="img/Perrin.png" alt="">
|
||||
<a href="Pages/Card Football.html" class="button">Voir plus</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>Card 2</h2>
|
||||
<p>card with 3D effect of pokemon Palkia</p>
|
||||
<img class="img" src="img/Carte.png" alt="">
|
||||
<a href="Pages/Card Pokemon.html" class="button">Voir plus</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user