前端网页设计期末大作业|纯原生Html+Css+JavaScript关于旅游主题网站|初学者必备
如果您觉得这篇文章有帮助的话!给个点赞和评论支持下吧,感谢~
作者:哇子
Hello,大家好,我是哇子!前几天帮一位同学做了一个关于网页设计的期末大作业,给大家演示下,我们本地启动liveserver,访问5500端口,大致分为首页、关于页、注册登录页,注册登录页就是包括注册和登录两个表单,表单之间有个动画切换效果,关于页就是关于站长的一些信息,首页呢,最上方是一个轮播图,下面依次就是一些图文展示,包括小红书链接、bilibili视频播放等,网站支持响应式,也就是说在移动端同样是适配的,最后需要源码的同学可以评论或者私信我
整体效果如下:
下面展示部分源码:
轮播图源码:
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
| <div class="swiper-img"> <div style="width: 100%;height: 100%;background-color: aqua;"> <img src="./images/swiper1.png" style="width: 100%;height: 100%;object-fit: cover;"/> </div> <div style="width: 100%;height: 100%;background-color: rgb(158, 221, 11);"> <img src="./images/swiper2.png" style="width: 100%;height: 100%;object-fit: cover;"/> </div> <div style="width: 100%;height: 100%;background-color: rgb(194, 18, 179);"> <img src="./images/swiper3.png" style="width: 100%;height: 100%;object-fit: cover;"/> </div> <div style="width: 100%;height: 100%;background-color: blue;"> <img src="./images/swiper4.png" style="width: 100%;height: 100%;object-fit: cover;"/> </div> </div> <style> .swiper-img { display: flex; width: 400%; height: 100%; transition: transform 0.5s ease-in-out; } .swiper-btns { position: absolute; bottom: 10%; left: 50%; width: 415px; height: 50px; border-radius: 59px; background: rgba(255, 255, 255, .7); backdrop-filter: blur(6px); transform: translateX(-50%); display: flex; z-index: 9; padding: 2px; } .swiper-btns>.btn-box{ flex: 1; height: 100%; border-radius: 25px; position: relative; z-index: 99; color: aliceblue; display: flex; justify-content: center; align-items: center; cursor: pointer; gap: 6px; font-size: 16px; } .swiper-btns>.btn-box>svg{ font-size: 24px; } .swiper-btns>.btn-box.active{ color: #329DEF; } .swiper-btns>.btn-bg{ position: absolute; z-index: 10; background-color: #ffffff; border-radius: 25px; height: calc(100% - 4px); transition: all 0.3s ease-in-out; left: 2px; width: calc(100% / 4); } </style> <script> let currentIndex = 0; const slides = $('.swiper-img>div'); const totalSlides = slides.length;
function showSlide(index) { const swiperboxWidth = $('.swiper-box').width() currentIndex = (index + totalSlides) % totalSlides const offset = -currentIndex * swiperboxWidth $('.swiper-img').css('transform', `translateX(${offset}px)`); const btnBoxes = document.querySelectorAll(".btn-box"); const btnBg = document.querySelector(".btn-bg"); const btnBoxesWidth = btnBoxes[0].getBoundingClientRect().width
btnBoxes.forEach(box => box.classList.remove("active")); btnBoxes[currentIndex].classList.add("active"); btnBg.style.left = `${currentIndex * btnBoxesWidth + 2}px` }
function nextSlide() { showSlide(currentIndex + 1); }
function prevSlide() { showSlide(currentIndex + 1); }
let timer = setInterval(nextSlide, 3000); </script>
|
登录注册源码:
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
| <div class="all-box"> <div class="margin-box"> <div class="fm-box"> <img src="./images/loginfm.png" style="width: 100%;height: 100%;object-fit: contain;"/> </div> <div class="rl-box"> <div class="change-btn"> <span class="login active" id="login">登录</span> <span class="registe" id="registe">注册</span> </div> <div class="relo-box"> <div class="inner-box"> <div class="login-box" id="login-box"> <input type="text" placeholder="请输入账号" class="login-zh"/> <input type="password" placeholder="请输入密码" class="login-mm"/> <div class="login-btn">登录</div> <div class="file-agree">登录即视为同意服务协议</div> </div> <div class="regist-box active" id="regist-box"> <input type="text" placeholder="请输入注册账号" class="login-zh"/> <input type="password" placeholder="请输入注册密码" class="login-mm"/> <div class="login-btn">注册</div> <div class="file-agree">注册即视为同意服务协议</div> </div> </div> </div> </div> </div> </div> <script> $(document).ready(function() { $('#login').on('click', function() { $(this).addClass('active'); $('#registe').removeClass('active'); $('#regist-box').addClass('active'); $('#login-box').removeClass('active'); $('.inner-box').css('transform', 'translateX(0)'); });
$('#registe').on('click', function() { $(this).addClass('active'); $('#login').removeClass('active'); $('#login-box').addClass('active'); $('#regist-box').removeClass('active'); $('.inner-box').css('transform', 'translateX(-50%)'); }); }); </script>
|