热门标签 | HotTags
当前位置:  开发笔记 > 前端 > 正文

jquery点击链接,展开导航栏相应位置

想要达到的效果:例如:点击男士,弹出展开右侧男士导航栏,怎么修改jquery达到这样的功能

想要达到的效果:例如:点击男士,弹出展开右侧男士导航栏,怎么修改jquery达到这样的功能
Homepage



   





   


   


       

全部产品



       

       

       

       

   









这是js部分

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
jQuery(document).ready(function($){

    var $lateral_menu_trigger = $('#cd-menu-trigger'),

        $content_wrapper = $('.cd-main-content'),

        $navigation = $('header');



    //open-close lateral menu clicking on the menu icon

    $lateral_menu_trigger.on('click', function(event){

        event.preventDefault();

       

        $lateral_menu_trigger.toggleClass('is-clicked');

        $navigation.toggleClass('lateral-menu-is-open');

        $content_wrapper.toggleClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){

            // firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden

            $('body').toggleClass('overflow-hidden');

        });

        $('#cd-lateral-nav').toggleClass('lateral-menu-is-open');

       

        //check if transitions are not supported - i.e. in IE9

        if($('html').hasClass('no-csstransitions')) {

            $('body').toggleClass('overflow-hidden');

        }

    });



    //close lateral menu clicking outside the menu itself

    $content_wrapper.on('click', function(event){

        if( !$(event.target).is('#cd-menu-trigger, #cd-menu-trigger span') ) {

            $lateral_menu_trigger.removeClass('is-clicked');

            $navigation.removeClass('lateral-menu-is-open');

            $content_wrapper.removeClass('lateral-menu-is-open').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){

                $('body').removeClass('overflow-hidden');

            });

            $('#cd-lateral-nav').removeClass('lateral-menu-is-open');

            //check if transitions are not supported

            if($('html').hasClass('no-csstransitions')) {

                $('body').removeClass('overflow-hidden');

            }



        }

    });



    //open (or close) submenu items in the lateral menu. Close all the other open submenu items.

    $('.item-has-children').children('a').on('click', function(event){

        event.preventDefault();

        $(this).toggleClass('submenu-open').next('.sub-menu').slideToggle(200).end().parent('.item-has-children').siblings('.item-has-children').children('a').removeClass('submenu-open').next('.sub-menu').slideUp(200);

    });

});

这是css部分

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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
.cd-main-content {

  /* set a min-height and a z-index to be sure that the main element completely covers the lateral menu */

  min-height: 100%;

  position: relative;

  background-color: white;

  z-index: 2;

  padding-top: 50px;

  /* Force Hardware Acceleration in WebKit */

  -webkit-transform: translateZ(0);

  -webkit-backface-visibility: hidden;

  -webkit-transition-property: -webkit-transform;

  -moz-transition-property: -moz-transform;

  transition-property: transform;

  -webkit-transition-duration: 0.4s;

  -moz-transition-duration: 0.4s;

  transition-duration: 0.4s;

}

.cd-main-content.lateral-menu-is-open {

  /* translate to show the lateral menu - all content needs to be put in the .cd-main-content to translate*/

  -webkit-transform: translateX(-260px);

  -moz-transform: translateX(-260px);

  -ms-transform: translateX(-260px);

  -o-transform: translateX(-260px);

  transform: translateX(-260px);

}

@media only screen and (min-width: 768px) {

  .cd-main-content {

    padding-top: 70px;

  }

}



header {

  position: absolute;

  top: 0;

  left: 0;

  height: 75px;

  width: 100%;

  background: #222222;

  z-index: 3;

  /* Force Hardware Acceleration in WebKit */

  -webkit-transform: translateZ(0);

  -webkit-backface-visibility: hidden;

  -webkit-transition-property: -webkit-transform;

  -moz-transition-property: -moz-transform;

  transition-property: transform;

  -webkit-transition-duration: 0.4s;

  -moz-transition-duration: 0.4s;

  transition-duration: 0.4s;

}

header.lateral-menu-is-open {

  /* translate to show the lateral menu */

  -webkit-transform: translateX(-260px);

  -moz-transform: translateX(-260px);

  -ms-transform: translateX(-260px);

  -o-transform: translateX(-260px);

  transform: translateX(-260px);

}

header.is-fixed {

  position: fixed;

}

@media only screen and (min-width: 768px) {

  header {

    height: 75px;

  }

}



#cd-logo {

  display: block;

  float: left;

  margin: 25px 0 0 25px;

}

#cd-logo img {

  display: block;

  height: 20px;

}

@media only screen and (min-width: 768px) {

  #cd-logo {

    margin: 25px 0 0 142px;

  }

}



#cd-top-nav {

  position: absolute;

  top: 0;

  right: 120px;

  height: 100%;

  display: none;

}

#cd-top-nav ul {

  height: 100%;

  padding-top: 18px;

}

#cd-top-nav li {

  display: inline-block;

  margin-right: 1em;

}

#cd-top-nav a {

  display: inline-block;

  padding: .5em;

  color: #FFF;

  text-transform: uppercase;

  font-weight: 600;

}

#cd-top-nav a.current {

  background-color: #242e30;

}

.no-touch #cd-top-nav a:hover {

  color: rgba(255, 255, 255, 0.7);

}

@media only screen and (min-width: 768px) {

  #cd-top-nav {

    display: block;

  }

}



#cd-lateral-nav {

  font-size: 1.2em;

}





#cd-menu-trigger {

  position: absolute;

  right: 0;

  top: 0;

  height: 100%;

  width: 50px;

  background-color: #222222;

}

#cd-menu-trigger .cd-menu-text {

  height: 100%;

  text-transform: uppercase;

  color: #FFF;

  font-weight: 600;

  display: none;

}

#cd-menu-trigger .cd-menu-icon {

  /* this span is the central line in the menu menu */

  display: inline-block;

  position: absolute;

  left: 50%;

  top: 50%;

  bottom: auto;

  right: auto;

  -webkit-transform: translateX(-50%) translateY(-50%);

  -moz-transform: translateX(-50%) translateY(-50%);

  -ms-transform: translateX(-50%) translateY(-50%);

  -o-transform: translateX(-50%) translateY(-50%);

  transform: translateX(-50%) translateY(-50%);

  width: 18px;

  height: 2px;

  background-color: #FFF;

  /* these are the upper and lower lines in the menu menu */

}

#cd-menu-trigger .cd-menu-icon::before, #cd-menu-trigger .cd-menu-icon:after {

  content: '';

  width: 100%;

  height: 100%;

  position: absolute;

  background-color: inherit;

  left: 0;

  /* Force Hardware Acceleration in WebKit */

  -webkit-transform: translateZ(0);

  -webkit-backface-visibility: hidden;

}

#cd-menu-trigger .cd-menu-icon::before {

  bottom: 5px;

}

#cd-menu-trigger .cd-menu-icon::after {

  top: 5px;

}

#cd-menu-trigger.is-clicked .cd-menu-icon {

  background-color: rgba(255, 255, 255, 0);

}

#cd-menu-trigger.is-clicked .cd-menu-icon::before, #cd-menu-trigger.is-clicked .cd-menu-icon::after {

  background-color: white;

}

#cd-menu-trigger.is-clicked .cd-menu-icon::before {

  bottom: 0;

  -webkit-transform: rotate(45deg);

  -moz-transform: rotate(45deg);

  -ms-transform: rotate(45deg);

  -o-transform: rotate(45deg);

  transform: rotate(45deg);

}

#cd-menu-trigger.is-clicked .cd-menu-icon::after {

  top: 0;

  -webkit-transform: rotate(-45deg);

  -moz-transform: rotate(-45deg);

  -ms-transform: rotate(-45deg);

  -o-transform: rotate(-45deg);

  transform: rotate(-45deg);

}

@media only screen and (min-width: 768px) {

  #cd-menu-trigger {

    width: 110px;

    padding-left: 1.25em;

  }

  #cd-menu-trigger .cd-menu-text {

    display: inline-block;

    line-height: 70px;

  }

  #cd-menu-trigger .cd-menu-icon {

    left: auto;

    right: 1.25em;

    -webkit-transform: translateX(0);

    -moz-transform: translateX(0);

    -ms-transform: translateX(0);

    -o-transform: translateX(0);

    transform: translateX(0);

  }

}



#cd-lateral-nav {

  position: fixed;

  height: 100%;

  right: 0;

  top: 0;

  /* the secondary navigation is covered by the main element */

  z-index: 1;

  width: 260px;

  background-color: #242e30;

  overflow-y: auto;

  /* Force Hardware Acceleration in WebKit */

  -webkit-transform: translateZ(0);

  -webkit-backface-visibility: hidden;

  -webkit-transition-property: -webkit-transform;

  -moz-transition-property: -moz-transform;

  transition-property: transform;

  -webkit-transition-duration: 0.4s;

  -moz-transition-duration: 0.4s;

  transition-duration: 0.4s;

  /* this creates the subtle slide in animation of the navigation */

  -webkit-transform: translateX(80px);

  -moz-transform: translateX(80px);

  -ms-transform: translateX(80px);

  -o-transform: translateX(80px);

  transform: translateX(80px);

}

#cd-lateral-nav .cd-navigation {

  margin: 10px 0 16px;

}

#cd-lateral-nav .sub-menu {

  padding: 0 10px 20px 15px;

  display: none;

}

#cd-lateral-nav a {

  display: block;

  line-height: 4em;

  padding: 0 16px 0 32px;

  color: #aab5b7;

}

#cd-lateral-nav a.current {

  background-color: #3a4a4d;

  color: #FFF;

}

.no-touch #cd-lateral-nav a:hover {

  color: #FFF;

}

@media only screen and (min-width: 768px) {

  #cd-lateral-nav .cd-navigation {

    margin: 20px 0;

  }

}

#cd-lateral-nav.lateral-menu-is-open {

  -webkit-transform: translateX(0);

  -moz-transform: translateX(0);

  -ms-transform: translateX(0);

  -o-transform: translateX(0);

  transform: translateX(0);

  /* smooth the scrolling on touch devices - webkit browsers */

  -webkit-overflow-scrolling: touch;

}



/* style menu items which have a submenu  */

#cd-lateral-nav .item-has-children > a {

  position: relative;

  text-transform: uppercase;

  font-weight: 600;

  /* this is the right arrow to show that the item has a submenu  */

}

#cd-lateral-nav .item-has-children > a::after {

  content: '';

  display: block;

  height: 11px;

  width: 8px;

  position: absolute;

  top: 50%;

  bottom: auto;

  -webkit-transform: translateY(-50%);

  -moz-transform: translateY(-50%);

  -ms-transform: translateY(-50%);

  -o-transform: translateY(-50%);

  transform: translateY(-50%);

  right: 1em;

  background: url("../img/cd-arrow.svg") no-repeat center center;

  background-size: 8px 11px;

  -webkit-transition-property: -webkit-transform;

  -moz-transition-property: -moz-transform;

  transition-property: transform;

  -webkit-transition-duration: 0.2s;

  -moz-transition-duration: 0.2s;

  transition-duration: 0.2s;

}

#cd-lateral-nav .item-has-children > a.submenu-open::after {

  -webkit-transform: translateY(-50%) rotate(90deg);

  -moz-transform: translateY(-50%) rotate(90deg);

  -ms-transform: translateY(-50%) rotate(90deg);

  -o-transform: translateY(-50%) rotate(90deg);

  transform: translateY(-50%) rotate(90deg);

}



推荐阅读
author-avatar
乌鸦bz_371
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有