-
Notifications
You must be signed in to change notification settings - Fork 0
/
M-IMG-Hover.html
145 lines (138 loc) · 4.42 KB
/
M-IMG-Hover.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
margin: 0;
padding: 0;
text-decoration: none;
}
main{
position: relative;
}
body {
overflow-x: hidden;
background-color: black;
}
ul {
font-size: 1.5rem;
display: flex;
justify-content: space-around;
align-items: center;
list-style: none;
padding: 1rem;
}
li {
color: white;
}
#tital {
text-align: center;
border-bottom: 2px solid white;
border-top: 2px solid white;
margin: 1rem;
color: white;
}
</style>
<title>DOM Projects</title>
<style>
.card{
color: white;
font-family:'Courier New', Courier, monospace;
}
.elem h1{
font-size: 7em;
mix-blend-mode: difference;
}
.last{
border-bottom: 1px solid white;
}
.elem{
border-top: 1px solid white;
position: relative;
cursor: pointer;
}
.elem img{
width: 30rem;
height: 30rem;z-index: -1;
object-fit: cover;
object-position: top;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
transition: all linear 0.3s;
opacity: 0;
}
</style>
</head>
<body>
<main>
<nav>
<ul>
<a href="index.html">
<li>FB-FEATURE</li>
</a>
<a href="INSTA-HEART.html">
<li>INSTA-HEART</li>
</a>
<a href="MOUSE-CRSR.html">
<li>MOUSE-CRSR</li>
</a>
<a href="M-IMG-Hover.html">
<li>M-IMG-Hover</li>
</a>
<a href="INSTA_STORY.html">
<li>INSTA_STORY</li>
</a>
</ul>
</nav>
<h1 id="tital">IMAGE HOVER EEFFECT</h1>
<div class="card">
<div class="elem ">
<h1>Mia Malkova</h1>
<img src="https://c4.wallpaperflare.com/wallpaper/946/190/354/mia-malkova-portrait-women-hd-wallpaper-preview.jpg">
</div>
<div class="elem">
<h1>Valentina Nappi</h1>
<img src="https://c4.wallpaperflare.com/wallpaper/283/427/643/valentina-nappi-model-women-women-with-glasses-wallpaper-preview.jpg">
</div>
<div class="elem">
<h1>Lana Rhoades</h1>
<img src="https://c4.wallpaperflare.com/wallpaper/244/899/830/lana-rhoades-model-women-blue-eyes-wallpaper-preview.jpg">
</div>
<div class="elem">
<h1>Lovely Ghosh</h1>
<img src="https://www.suddenviral.com/wp-content/uploads/2022/11/Call-Me-Sherni-photo-819x1024.jpg">
</div>
<div class="elem last">
<h1>Kendra Lust</h1>
<img src="https://c4.wallpaperflare.com/wallpaper/375/864/894/kendra-lust-minidress-women-pornstar-wallpaper-preview.jpg">
</div>
</div>
</main>
<script>
//when i hover the line 1 it will only show image of line one and when i go to line 2 it will hide line image and show line 2 image and so on
function mouseImageHover() {
let elem = document.querySelectorAll('.elem');
let hImage = document.querySelectorAll('.elem img');
elem.forEach(element => {
console.log(element.childNodes[3]);
element.addEventListener('mouseenter',()=>{
element.childNodes[3].style.opacity = 1;
});
element.addEventListener('mouseleave',()=>{
element.childNodes[3].style.opacity = 0;
});
element.addEventListener('mousemove',function(dets) {
element.childNodes[3].style.left = dets.x + 'px';
element.childNodes[3].style.top = dets.y + 'px';
})
});
}
mouseImageHover();
</script>
</body>
</html>