老师请教个问题
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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" > < style type = "text/css" > /* 通用样式 */ *{ margin: 0; padding: 0; list-style: none; text-decoration: none; } html{ font-size: 100px; } body{ font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,\\5FAE\8F6F\96C5\9ED1,Arial,sans-serif; font-size: 14px; } /* 第一区域 */ header{ width: 100%; background: #B2C5CC; display: flex; flex-direction: column; align-items: center; } header div{ display: none; } .nav{ font-size: 12px; color: #757575; display: flex; margin: 20px auto 0 auto; align-items: baseline; width: 4rem; justify-content: space-between; } .nav li:first-child{ color: #afafaf; } img{ display: block; margin: 50px 0 20px 0; } header span{ margin-bottom: 30px; color: #f4fcff; } header input{ width: 140px; height: 36px; text-align: center; line-height: 36px; margin-bottom: 100px; background: #fff; border: none; box-shadow: 0 0 1px gray; } /* 第二区域 */ .second-area ul{ width: 100%; border-bottom: 1px solid #cccccc; display: flex; flex: 1 0; justify-content: space-between; } .second-area ul li{ margin: 15px auto; color: #bababa; } .second-area ul li:first-child{ color: #545454; } /* 第三区域 */ .third-area{ width: 100%; height: 248px; display: flex; flex-direction: column; align-items: center; justify-content: center; } .third-area h3{ margin-bottom: 20px; color: #616b6d; } .third-area p{ width: 45%; color: #adadad; } /* 第四区域 */ .fourth-area ul{ background: #f4f4f4; width: 100%; border-bottom: 1px solid #cccccc; display: flex; flex: 1 0; justify-content: space-between; align-items: center; } .fourth-area ul li{ margin: 15px 40px; color: #bababa; } .fourth-area ul li:first-child{ font-size: 18px; margin: 15px 40px; color: #6a6a6a; } .fourth-area ul li:last-child a{ color: black; } /* 第五区域 */ .five-area{ background: url(素材/bg.jpg); padding: 40px 20px; } .five-area ul{ display: flex; flex-wrap: wrap; align-content: center; justify-content: space-between; } .five-area ul li { width: 30%; height: auto; display: flex; } .five-area ul li img{ width: 100%; height: 145px; margin: 10px 0; } /* 页脚 */ footer{ color: black; width: 100%; display: flex; align-items: center; justify-content: center; margin: 18px 0; } /* iphone6以下响应式 */ @media screen and (max-width: 380px) { header{ width: 100%; background: #B2C5CC; display: flex; flex-direction: column; align-items: center; position: relative; } header div{ padding: 10px 0; width: 100%; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.2); position: relative; background:#7EA6B1; display: flex; align-items: center; justify-content: center; } header div p{ margin: 0 auto; font-size: 16px; } header div input{ width: 15px; height: 15px; background: #7EA6B1; border: 1.5px solid #afc9d6; position: absolute; right: 20px; } .nav{ font-size: 12px; color: #fff; display: flex; flex-direction: column; background:#7EA6B1; margin: 0 auto 0 auto; align-items: center; width: 100%; justify-content: space-between; position: absolute; top: 40px; -webkit-animation: switchColor 1s; } .nav li:first-child{ color: #fff; } .nav li{ width: 100%; font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.6); text-align: center; color: #fff; } .hide{ display: none; } .slide{ -webkit-animation: slide 1s; font-size: 12px; color: #fff; display: flex; flex-direction: column; background:#7EA6B1; margin: 0 auto 0 auto; align-items: center; width: 100%; justify-content: space-between; position: absolute; top: -200px; } img{ display: block; width: 22%; margin: 30px 0 20px 0; } header span{ margin-bottom: 20px; font-size: 10px; color: #f4fcff; } header input{ width: 110px; height: 30px; text-align: center; line-height: 30px; margin-bottom: 100px; background: #fff; border: none; box-shadow: 0 0 1px gray; } /* 第二阶段 */ .second-area ul{ font-size: 10px; width: 100%; border-bottom: 1px solid #cccccc; display: flex; flex: 1 0; justify-content: space-between; } .second-area ul li{ margin: 15px auto; color: #bababa; } .second-area ul li:first-child{ color: #545454; } /* 第三区域 */ .third-area{ width: 100%; font-size: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 20px auto; } .third-area h3{ margin-bottom: 20px; color: #616b6d; } .third-area p{ width: 50%; color: #adadad; } /* 第四区域 */ .fourth-area ul{ background: #f4f4f4; width: 100%; border-bottom: 1px solid #cccccc; display: flex; flex-direction: column; flex: 1 0; justify-content: center; align-items: space-around; } .fourth-area ul li{ margin: 0px 40px 10px 40px; color: #bababa; } .fourth-area ul li:first-child{ font-size: 18px; margin: 10px 40px 10px 40px; color: #bababa; } .fourth-area ul li:last-child a{ color: black; } /* 第五区域 */ .five-area{ background: url(素材/bg.jpg); padding: 40px 20px; display: flex; flex-direction: column; justify-content: space-around; } .five-area ul{ display: flex; flex-wrap: wrap; align-content: center; justify-content: space-between; } .five-area ul li { width: 48%; height: auto; display: flex; } .five-area ul li img{ width: 100%; height: 90px; margin: 10px 0; } /* 页脚 */ footer{ font-size: 8px; color: black; width: 100%; display: flex; align-items: center; justify-content: center; margin: 18px 0; } @keyframes switchColor{ 0% {top: -200px} 100%{top: 40px} } @keyframes slide{ 0% {top: 40px} 100%{top: -200px} } } /* 第二阶段 */ </ style > < title >7-2作业</ title > </ head > < body > < div id = "web-page" > < header class = "first-area" > < div id = "top" style = "z-index: 2" > < p >imooc</ p > < input type = "button" name = "" class = "btn" > </ div > < ul class = "nav hide" style = "z-index: 1" > < li >前端</ li > < li >JAVA</ li > < li >IOS</ li > < li >Android</ li > < li >PHP</ li > </ ul > < img src = "素材/1.png" > < span >IMOOC</ span > < input type = "button" name = "" value = "start" > </ header > < div class = "second-area" > < ul > < li >关于慕课网</ li > < li >关于课程</ li > < li >核心团队</ li > < li >新增专题</ li > </ ul > </ div > < article class = "third-area" > < h3 >响应式</ h3 > < p >响应式布局是Ethan Marcotte在2010年5月份提出的一个概念,简而言之,就是一个网站能够兼容多个终端——而不是为每个终端做一个特定的版本。这个概念是为解决移动互联网浏览而诞生的。响应式布局可以为不同终端的用户提供更加舒适的界面和更好的用户体验,而且随着目前大屏幕移动设备的普及,用“大势所趋”来形容也不为过。随着越来越多的设计师采用这个技术,我们不仅看到很多的创新,还看到了一些成形的模式</ p > </ article > < div class = "fourth-area" > < ul > < li >IMOOC</ li > < li >welcome to < a href = "#" >www.imooc.com</ a ></ li > </ ul > </ div > < div class = "five-area" > < p >主打课程</ p > < ul > < li >< img src = "素材/1.jpg" alt = "" ></ li > < li >< img src = "素材/2.jpg" alt = "" ></ li > < li >< img src = "素材/3.jpg" alt = "" ></ li > < li >< img src = "素材/4.jpg" alt = "" ></ li > < li >< img src = "素材/5.jpg" alt = "" ></ li > < li >< img src = "素材/6.jpg" alt = "" ></ li > </ ul > </ div > < footer >copyright©2017 imooc.com All Rights Reserved</ footer > </ div > < script > var hedTop = document.getElementById('top'), btnOO = hedTop.getElementsByClassName('btn')[0], hide = document.getElementsByClassName('hide')[0]; btnOO.onclick = function(){ if (hide.className==="nav hide") { hide.className = "nav" }else if(hide.className === "nav"){ hide.className = "slide" }else if(hide.className === "slide"){ hide.className = "nav" } } </ script > </ body > </ html > |
老师我在IPHONE6点击两次按钮以后再切换到ipad下,因为JS原因替换了类,所以样式改变了,这种情况允许吗?
0
收起
正在回答
2回答
同学,你好。
我们做网站不能不让交互和切换啊,是要做响应式的操作。所以只要能影响到布局的都不可以。现在还没有掌握好布局技巧,还没有真正掌握布局的核心,如果做过多的拓展可能会影响你基础布局的学习。建议你先掌握课程中老师讲解的方式哦。
如果帮助到了你,欢迎采纳!
响应式开发与常用框架 2018
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧