so to understand my problem you can see THIS GIF dropdown works when i hover out at the bottom of the box or go to another dropdown but it’s stays when you hover out at the top or the right side of the div it’s litteraly an edge case. Here is my code JSFIDDLE or there is a snippet here.
Thanks for your help
JavaScript
x
8
1
$("[class^='iconWrapper']").mouseover(function(e) {
2
$("[class^='helpBox']").hide();
3
$(this).next("[class^='helpBox']").show();
4
});
5
6
$("[class^='helpBox']").mouseleave(function() {
7
$("[class^='helpBox']").hide();
8
});
JavaScript
1
268
268
1
.grid-container-PC {
2
display: grid;
3
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
4
grid-template-rows: 0.2fr 0.5fr;
5
gap: 0px 0px;
6
grid-template-areas: "topBar topBar topBar topBar topBar topBar" "navBar navBar navBar navBar navBar navBar";
7
padding: 0;
8
margin: 0;
9
}
10
11
.topBar {
12
grid-area: topBar;
13
width: 100%;
14
height: 4vh;
15
display: flex;
16
align-items: center;
17
border-bottom: 1px solid #ddd;
18
}
19
20
.navBar {
21
display: grid;
22
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
23
grid-template-rows: 1fr 0.65fr;
24
gap: 0px 0px;
25
grid-template-areas: ". mainBar mainBar mainBar mainBar ." "bottomBar bottomBar bottomBar bottomBar bottomBar bottomBar";
26
grid-area: navBar;
27
}
28
29
.mainBar {
30
display: grid;
31
grid-template-columns: 0.5fr 1fr 1fr 1fr;
32
grid-template-rows: 0.2fr 1fr;
33
gap: 0px 0px;
34
grid-template-areas: ". . . ." "logoBox searchBar searchBar cart";
35
grid-area: mainBar;
36
}
37
38
.searchBar {
39
grid-area: searchBar;
40
width: 100%;
41
height: 5vh;
42
}
43
44
.cart {
45
grid-area: cart;
46
}
47
48
.logoBox {
49
grid-area: logoBox;
50
width: 100%;
51
height: 100%;
52
}
53
54
.bottomBar {
55
width: 100%;
56
height: 100%;
57
grid-area: bottomBar;
58
background: rgb(245, 245, 245);
59
box-shadow: rgba(0, 0, 0, 0.64) 0px 2px 8px -5px;
60
}
61
62
.grid-container-mobile {
63
display: none
64
}
65
66
.cartWrapper {
67
display: flex;
68
position: relative;
69
-webkit-box-align: center;
70
align-items: center;
71
width: 90%;
72
margin-left: 5%;
73
}
74
75
.iconWrapper1,
76
.iconWrapper2,
77
.iconWrapper3 {
78
display: flex;
79
width: 33.33%;
80
}
81
82
.iconContent1,
83
.iconContent2,
84
.iconContent3 {
85
height: 56px;
86
min-width: 100%;
87
display: flex;
88
align-items: center;
89
display: -webkit-box;
90
display: -moz-box;
91
display: -ms-flexbox;
92
display: -webkit-flex;
93
}
94
95
.tileLink {
96
-webkit-box-align: center;
97
align-items: center;
98
display: flex;
99
flex-direction: column;
100
-webkit-box-pack: center;
101
width: 100%;
102
height: 100%;
103
color: black;
104
}
105
106
.iconPic {
107
font-size: 28px;
108
width: 32px;
109
height: 32px;
110
}
111
112
.tileLink:hover {
113
color: black;
114
text-decoration: none;
115
}
116
117
.iconText {
118
font-size: 11px;
119
line-height: 30px;
120
white-space: nowrap;
121
text-align: center;
122
padding: 0 7px 0 7px;
123
}
124
125
.iconContent1:hover,
126
.iconContent2:hover,
127
.iconContent3:hover {
128
border-top: none;
129
border-radius: 8px 8px 0px 0px;
130
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 2px 1px, rgba(0, 0, 0, 0.16) 0px 4px 8px 0px;
131
background: rgb(255, 255, 255);
132
z-index: 11;
133
-webkit-box-shadow: 10px 0px 6px -3px rgba(0, 0, 0, 0.16);
134
-moz-box-shadow: 10px 0px 6px -3px rgba(0, 0, 0, 0.16);
135
box-shadow: 5px 0px 6px -3px rgba(0, 0, 0, 0.16);
136
}
137
138
.helpBox1,
139
.helpBox2,
140
.helpBox3 {
141
display: none;
142
z-index: 10;
143
position: absolute;
144
top: 100%;
145
min-width: 200px;
146
background-color: rgb(255, 255, 255);
147
border-radius: 0px 8px 8px;
148
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 2px 1px, rgba(0, 0, 0, 0.16) 0px 4px 8px 0px;
149
padding: 8px 0px 15px;
150
left: 0px;
151
}
152
153
.helpBox2 {
154
left: 33.33%;
155
min-width: 250px;
156
}
157
158
.helpBox3 {
159
right: 0%;
160
min-width: 250px;
161
}
162
163
.tileListHelpTitle {
164
padding: 0px 16px;
165
font-weight: 500;
166
font-family: 'Montserrat', sans-serif;
167
color: rgb(112, 112, 112);
168
font-size: 15px;
169
}
170
171
.listHelpBox {
172
list-style-type: none;
173
padding: 0;
174
margin-bottom: 0rem;
175
}
176
177
.listStyleHelpBox {
178
list-style-type: none;
179
box-sizing: inherit;
180
padding: 0px;
181
margin: 0px;
182
height: 3.4vh;
183
width: 100%;
184
font-size: 14px;
185
}
186
187
.linkHelpBox {
188
padding: 0px 16px;
189
width: 100%;
190
height: 100%;
191
display: flex;
192
-webkit-box-pack: justify;
193
justify-content: space-between;
194
-webkit-box-align: center;
195
align-items: center;
196
}
197
198
a.linkHelpBox {
199
color: rgb(112, 112, 112);
200
}
201
202
a:hover.linkHelpBox {
203
color: rgb(112, 112, 112);
204
text-decoration: none;
205
}
206
207
.listStyleHelpBox:hover {
208
background-color: rgb(245, 245, 245);
209
}
210
211
.dayBoxHelp,
212
.hourBoxHelp {
213
font-family: 'Montserrat', sans-serif;
214
color: rgb(112, 112, 112);
215
font-size: 10px;
216
}
217
218
.loginButtonHelpBox .linkLoginHelpBox,
219
.loginButtonHelpBox .linkCreateHelpBox {
220
background: rgb(0, 130, 250);
221
color: rgb(255, 255, 255);
222
border: 1px solid rgb(0, 130, 250);
223
border-radius: 20px;
224
min-width: 100%;
225
text-align: center;
226
padding: 3px 0 3px 0;
227
}
228
229
.loginButtonHelpBox .linkCreateHelpBox {
230
color: rgb(0, 130, 250);
231
border: 1px solid rgb(0, 130, 250);
232
background: rgb(255, 255, 255);
233
}
234
235
.hrLogin {
236
margin: 22px 0px 21px;
237
border-top: 1px solid rgb(221, 221, 221);
238
position: relative;
239
}
240
241
.textHrLogin {
242
font-size: 13px;
243
line-height: 16px;
244
text-align: center;
245
color: rgb(112, 112, 112);
246
background-color: rgb(255, 255, 255);
247
position: absolute;
248
top: 90px;
249
left: 50%;
250
transform: translateX(-50%);
251
padding: 0px 16px;
252
width: 130px;
253
}
254
255
.categoryPC {
256
width: 100%;
257
height: 100%;
258
padding: 9px 0 9px;
259
}
260
261
.categoryPCLink {
262
font-family: 'Montserrat', sans-serif;
263
display: flex;
264
flex-direction: column;
265
justify-content: center;
266
align-items: center;
267
padding-top: 3px;
268
}
JavaScript
1
89
89
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
2
<div class="grid-container-PC">
3
<div class="topBar">
4
<div class="topBarWrapper">
5
<div class="container-fluid"></div>
6
</div>
7
</div>
8
9
<div class="navBar">
10
<div class="mainBar">
11
<div class="searchBar"></div>
12
13
<div class="cart">
14
<div class="cartWrapper">
15
<div class="iconWrapper1">
16
<div class="iconContent1">
17
<a class="tileLink" href=""></a>
18
19
<div class="iconPic"></div>
20
21
<div class="iconText">
22
test1
23
</div>
24
</div>
25
</div>
26
27
<div class="helpBox1"></div>
28
29
<div class="iconWrapper2">
30
<div class="iconContent2">
31
<a class="tileLink" href="{%%20url%20'order'%20%}"></a>
32
33
<div class="iconPic"></div>
34
35
<div class="iconText">
36
test2
37
</div>
38
</div>
39
</div>
40
41
<div class="helpBox2">
42
<div class="tileListHelpTitle">
43
Test value
44
</div>
45
46
<div class="loginButtonHelpBox">
47
<div class="helloMsgLogin">
48
Test valuej
49
</div><a href=""></a>
50
51
<div class="linkLoginHelpBox"></div>
52
<hr class="hrLogin" />
53
54
<p class="textHrLogin">Test value</p>
55
56
<div class="linkCreateHelpBox"></div>
57
</div>
58
59
<ul class="listHelpBox">
60
<li class="listStyleHelpBox"><a class="linkHelpBox">Test Value</a></li>
61
</ul>
62
</div>
63
64
<div class="iconWrapper3">
65
<div class="iconContent3">
66
<a class="tileLink" href=""></a>
67
68
<div class="iconPic"></div>
69
70
<div class="iconText">
71
test3
72
</div>
73
</div>
74
</div>
75
76
<div class="helpBox3">
77
<div class="tileListHelpTitle">
78
text
79
</div>
80
</div>
81
</div>
82
</div>
83
84
<div class="logoBox">
85
<div class="logoWrapper"></div>
86
</div>
87
</div>
88
</div>
89
</div>
Advertisement
Answer
You need to wrap mouseleave function to iconWrapper class
and also need to assign mouseleave to helpBox cause you don’t wanna close helpbox window on moving out of heading
JavaScript
1
16
16
1
$("[class^='iconWrapper']").mouseover(function(e) {
2
$("[class^='helpBox']").hide();
3
$(this).next("[class^='helpBox']").show();
4
});
5
6
$("[class^='iconWrapper']").mouseleave(function() {
7
let ele=$(this).next("[class^='helpBox']");
8
$(ele).mouseover(function(){
9
$(this).show();
10
});
11
$(ele).mouseleave(function(){
12
$(this).hide();
13
});
14
$(ele).hide();
15
});
16