menu con diseno responsive no funciona
Publicado por cosmito (16 intervenciones) el 18/02/2020 01:21:17
Estoy desarrollando un menu responsive, en el tutorial trabaja excelente pero en mi localhost no funciona,
este es el CODIGO HTML:
************************************************************************************
LOS ESTILOS
*****************************************************************
CODIGO JS
este es el CODIGO 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
<meta charset="UTF-8">
<title>Menu</title><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="estilos.css">
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<div class="wrapper">
<h1>Menu</h1>
<a class="menu-btn" onclick="toggleMenu()"></a>
<section class="one" onclick="goToPage(0)">
<h1>Servicios</h1>
</section>
<section class="two" onclick="goToPage(1)">
<h1>Citas</h1>
</section>
<section class="three" onclick="goToPage(2)">
<h1>Mensajes</h1>
</section>
<section class="four" onclick="goToPage(3)">
<h1>Settings</h1>
</section>
</div>
</body>
************************************************************************************
LOS ESTILOS
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
@import url(https://fonts.googleapis.com/css?family=Lato);
$color1: #f75b5b;
$color2: #c84051;
$color3: #4f3462;
$color4: #794d9a;
* {
font-family: inherit;
-webkit-font-smoothing: antialiased;
}
html {
font-size: 62.5%;
font-family: 'Lato', sans-serif;
}
body {
background: #1f252d;
}
.wrapper {
height: 480px;
width: 320px;
background: #2e394b;
overflow: hidden;
position: relative;
margin: 20px auto 0;
}
.menu-btn {
position: absolute;
z-index: 10;
top: 0;
left: 0;
height: 70px;
width: 54px;
cursor: pointer;
background: url(https://iamturner.co.uk/codepen/menu-icon.png) no-repeat center;
background-size: 44px;
&:active {
opacity: 0.2;
}
}
section {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 8px 8px 0 0;
-webkit-transition: -webkit-transform 0.3s;
&.one {
background: $color1;
-webkit-transition-delay: 0s;
}
&.two {
background: $color2;
-webkit-transition-delay: 0.05s;
}
&.three {
background: $color3;
-webkit-transition-delay: 0.1s;
}
&.four {
background: $color4;
-webkit-transition-delay: 0.15s;
}
&.after {
-webkit-transform: translateY(100%);
}
}
h1 {
color: white;
font-weight: 500;
font-size: 2rem;
text-align: center;
margin: 0;
line-height: 70px;
-webkit-user-select: none;
}
.page-one {
section {
&.one { -webkit-transition-delay: 0s; }
&.two { -webkit-transition-delay: 0.15s; }
&.three { -webkit-transition-delay: 0.1s; }
&.four { -webkit-transition-delay: 0.05s; }
}
}
.page-two {
section {
&.one { -webkit-transition-delay: 0s; }
&.two { -webkit-transition-delay: 0.05s; }
&.three { -webkit-transition-delay: 0.1s; }
&.four { -webkit-transition-delay: 0.05s; }
}
}
.menu-open {
section {
cursor: pointer;
&.one {
-webkit-transform: translateY(70px);
-webkit-transition-delay: 0.15s;
&:active {
background: lighten($color1, 3%);
}
}
&.two {
-webkit-transform: translateY(140px);
-webkit-transition-delay: 0.1s;
&:active {
background: lighten($color2, 3%);
}
}
&.three {
-webkit-transform: translateY(210px);
-webkit-transition-delay: 0.05s;
&:active {
background: lighten($color3, 3%);
}
}
&.four {
-webkit-transform: translateY(280px);
-webkit-transition-delay: 0s;
&:active {
background: lighten($color4, 3%);
}
}
}
&.page-one {
section {
&.one { -webkit-transition-delay: 0s; }
&.two { -webkit-transition-delay: 0.05s; }
&.three { -webkit-transition-delay: 0.1s; }
&.four { -webkit-transition-delay: 0.15s; }
}
}
&.page-two {
section {
&.one { -webkit-transition-delay: 0s; }
&.two { -webkit-transition-delay: 0.05s; }
&.three { -webkit-transition-delay: 0.1s; }
&.four { -webkit-transition-delay: 0.15s; }
}
}
}
*****************************************************************
CODIGO JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var pages = new Array('one', 'two', 'three', 'four');
function toggleMenu() {
document.getElementsByClassName('wrapper')[0].classList.toggle('menu-open');
}
function goToPage(page) {
var wrapper = document.getElementsByClassName('wrapper')[0];
var sections = document.getElementsByTagName('section');
for (i = 0; i < sections.length; i++) {
sections[i].classList.remove('before','after');
if (i > page) {
sections[i].classList.add('after');
}
}
wrapper.classList.remove('menu-open','page-one','page-two');
wrapper.classList.add('page-' + pages[page]);
}
Valora esta pregunta


0