当前位置: 首页 > news >正文

泉州模板建站定制国际财经新闻

泉州模板建站定制,国际财经新闻,郑州做网站设计的公司,wordpress onepageJSCSS实现滑动轮播图 使用JS加CSS来实现的幻灯片&#xff0c;主要使用的是CSS的transform属性中的translate来实现&#xff0c;适合与用户交互的轮播图&#xff0c;展现轮播图的数量&#xff0c;用户可自由进行选择。 <!DOCTYPE html> <html lang"en">&…

 JS+CSS实现滑动轮播图

使用JS加CSS来实现的幻灯片,主要使用的是CSS的transform属性中的translate来实现,适合与用户交互的轮播图,展现轮播图的数量,用户可自由进行选择。

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>* {margin: 0;padding: 0;list-style: none;}.cardBox {width: 600px;height: 300px;box-shadow: 0 0 10px gray;border-radius: 5px;margin: 100px auto;position: relative;overflow: hidden;}.imgBox {width: 3600px;height: 300px;transition: all 1s;transform: translateX(0px);}.item {width: 600px;height: 300px;float: left;}.item img {width: 100%;}.btn {width: 20px;height: 20px;top: calc(50% - 20px);border-right: solid white;border-top: solid white;position: absolute;z-index: 99;opacity: .6;cursor: pointer;}.btn:hover {opacity: 1;}.left {left: 15px;transform: rotate(-135deg);}.right {right: 15px;transform: rotate(45deg);}.pointBox {display: flex;width: 50%;position: absolute;bottom: 15px;left: 50%;transform: translateX(-50%);justify-content: center;}.pointBox li {width: 8px;height: 8px;border-radius: 50%;background: gray;margin: 0 10px;opacity: .7;cursor: pointer;}.pointBox li:hover {opacity: 1;background-color: white;}</style>
</head><body><div class="cardBox"><div class="btn left"></div><div class="btn right"></div><ul class="imgBox"><li class="item"><img src="https://img2.baidu.com/it/u=2988589017,2923917558&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800" alt=""></li><li class="item"><img src="https://img2.baidu.com/it/u=3867960631,2923014190&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""srcset=""></li><li class="item"><img src="https://img0.baidu.com/it/u=891036130,2043934807&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""srcset=""></li><li class="item"><img src="https://img1.baidu.com/it/u=1304255642,2961408783&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""srcset=""></li><li class="item"><img src="https://img0.baidu.com/it/u=3822016102,3026244821&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=281" alt=""srcset=""></li><li class="item"><img src="https://img1.baidu.com/it/u=847956157,2750448390&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500" alt=""srcset=""></li></ul><ul class="pointBox"><li></li><li></li><li></li><li></li><li></li><li></li></ul></div><script>let card = document.querySelector('.cardBox ul')let cardBox = document.querySelector('.cardBox')let items = document.querySelectorAll(".item")let leftBtn = document.querySelector(".left")let rightBtn = document.querySelector(".right")let points = document.querySelectorAll(".pointBox li")let index = 0items.forEach((item, index) => {let translateX = index * 600item.style.left = `${translateX}px`})let timer = nullpoints[index].style.background = 'white'points[index].style.width = '16px'points[index].style.borderRadius = '5px'const initInterval = () => {timer = setInterval(() => {index++let pointIndex = index;points[pointIndex].style.background = 'white'points[pointIndex].style.width = '16px'points[pointIndex].style.borderRadius = '5px'if (pointIndex == 0) {points[5].style.background = 'gray'points[5].style.width = '8px'} else {points[pointIndex - 1].style.background = 'gray'points[pointIndex - 1].style.width = '8px'}let translateX = -index * 600card.style.transform = `translateX(${translateX}px)`if (index >= 5) {index = -1}}, 3000);}initInterval()cardBox.addEventListener("mouseover", () => {clearInterval(timer)})cardBox.addEventListener("mouseout", () => {initInterval()})// btn.addEventListener("mouseout", () => {//   initInterval()// })leftBtn.onclick = function () {if (timer) {clearInterval(timer)}if (index <= 0) {index = 6}index--let translateX = -index * 600card.style.transform = `translateX(${translateX}px)`}rightBtn.onclick = function () {if (timer) {clearInterval(timer)}index++let translateX = -index * 600card.style.transform = `translateX(${translateX}px)`if (index >= 5) {index = -1}}points.forEach((item, i) => {item.onclick = () => {points.forEach(element => {element.style.background = 'gray'element.style.width = '8px'element.style.borderRadius = '50%'});item.style.background = 'white'item.style.width = '16px'item.style.borderRadius = '5px'index = i;let translateX = -index * 600card.style.transform = `translateX(${translateX}px)`}})</script>
</body></html>

 

 

JS+CSS实现浅入浅出轮播图

使用CSS的动画属性以及透明度属性来进行设置,显示轮播图数量,通过点击轮播图中的索引点来切换轮播图。适合需要和用户交互的简单轮播图

http://www.hkea.cn/news/281079/

相关文章:

  • 大连做网站仟亿科技最新域名查询
  • 网站开发实施计划与安排宁波网络推广方式
  • 企业网站建设公司注意哪些问题软件开发外包公司
  • abc网站建设怎么样yandex引擎搜索入口
  • wordpress屏蔽f12广州seo网络优化公司
  • 南宁网站建设推广服务云服务器免费
  • 大数据营销是什么seo站长
  • 建设政府网站的公司乐山网站seo
  • 仿站容易还是建站容易专业做灰色关键词排名
  • 做网站背景音乐管理课程培训
  • 网站建设可以自学吗品牌软文范文
  • 网站风格对比哪里有学计算机培训班
  • 做mla的网站网站优化哪家好
  • 网站注册的账号怎么注销线上营销活动有哪些
  • 国内做进口的电商网站网站推广软件哪个好
  • 谁有做那事的网站百度投诉中心入口
  • 免费单页网站在线制作沈阳seo排名优化教程
  • 廊坊网站建大型网站建站公司
  • 远程桌面做网站sem和seo区别与联系
  • 做贷款网站优化大师有用吗
  • 有没有便宜的网站制作制作网页教程
  • 医院网站制作优化关键词的方法有哪些
  • wordpress安装到网站吗泰安seo
  • 长春网站开发培训价格google play三件套
  • 做生存分析的网站有哪些国外新闻最新消息
  • 济南网站优化收费百度互联网营销
  • bootstrap响应网站模板下载发帖推广百度首页
  • 动态网站上的查询怎么做新媒体运营培训学校
  • 网站开发人员必备技能百度优化推广
  • 花都 网站建设百度推广怎么添加关键词