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

做分析图很好用的网站百度关键词搜索排名多少钱

做分析图很好用的网站,百度关键词搜索排名多少钱,徐州网站设计价位,自己做的网站打开速度慢代码在文章最后面(含图片URL) 实现功能 按向左按钮图片显示上一张按向右按钮图片显示下一张每隔2000毫秒显示下一张图底部三个圆点显示当前的图片的编号 实现流程 初始化图片数组 创建一个包含图片URL的数组,轮播时会通过这个数组来切换图…

代码在文章最后面(含图片URL)

实现功能

  1. 按向左按钮图片显示上一张
  2. 按向右按钮图片显示下一张
  3. 每隔2000毫秒显示下一张图
  4. 底部三个圆点显示当前的图片的编号

实现流程

  1. 初始化图片数组 创建一个包含图片URL的数组,轮播时会通过这个数组来切换图片。
  2. 创建当前索引变量 这个变量用来追踪当前显示的图片索引。
  3. 创建自动轮播图片函数 该函数负责更改轮播图中显示的图片,并根据当前索引更新指示器的状态。
  4. 创建指示器的函数 此函数在HTML中创建了与图片数量相同的指示器元素,并为第一个指示器添加了active-indicator类,以表示它是活动的。
  5. 下一张图片按钮 当用户点击“下一张”按钮时,这个函数会被触发。它将currentIndex加一,如果索引等于图片数组长度,则将索引重置为0,然后调用showImage函数来更新图片和指示器。
  6. 上一张图片按钮 当用户点击“上一张”按钮时,这个函数会被触发。它将currentIndex减一,如果索引小于0,则将索引设置为图片数组的最后一个元素的索引,然后调用showImage函数来更新图片和指示器。
  7. 创建事件监听器 将这些监听器绑定到“下一张”和“上一张”按钮上,当按钮被点击时,它们会调用相应的函数。
  8. 启动自动轮播 设置了一个定时器,每隔2000毫秒(2秒)调用一次nextImage函数,从而实现图片的自动轮播。

ONGD:通过操作DOM元素,用CSS类来控制显示的图片和当前图片指示器的状态,实现了图片轮播。

完整代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Carousel</title>
<style>body {display: flex;justify-content: center;align-items: center;height: 100vh;margin: 0;background-color: #f0f0f0;}.carousel {position: relative;width: 300px;height: 200px;border-radius: 8px;overflow: hidden;box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);}.carousel img {width: 100%;height: auto;}.controls {position: absolute;top: 50%;transform: translateY(-50%);width: 100%;display: flex;justify-content: space-between;padding: 0 10px;}.control-button {background-color: white;color: #333;font-size: 20px;width: 30px;height: 30px;border-radius: 50%;display: flex;justify-content: center;align-items: center;cursor: pointer;box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);}.indicator-container {position: absolute;bottom: 10px;left: 50%;transform: translateX(-50%);display: flex;}.indicator {background-color: #ccc;width: 10px;height: 10px;border-radius: 50%;margin: 0 4px;box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);}.active-indicator {background-color: black;}
</style>
</head>
<body>
<div class="carousel"><img src="" alt="Image" id="carousel-image"><div class="controls"><button class="control-button" id="prev-btn">👈</button><button class="control-button" id="next-btn">👉</button></div><div class="indicator-container" id="indicators"></div>
</div><script>const images = ['https://q9.itc.cn/q_70/images03/20240715/8319afaf350346a08a4d51b65638e39d.png','https://n.sinaimg.cn/sinacn20191106ac/42/w500h342/20191106/6b91-ihyxcrp9562392.jpg','https://n.sinaimg.cn/news/transform/20170412/D-Ac-fyecfam0465124.jpg'];let currentIndex = 0;function showImage(index) {document.getElementById('carousel-image').src = images[index];const indicators = document.getElementById('indicators').children;for (let i = 0; i < indicators.length; i++) {indicators[i].classList.remove('active-indicator');}indicators[index].classList.add('active-indicator');}function createIndicators() {const indicatorContainer = document.getElementById('indicators');for (let i = 0; i < images.length; i++) {const indicator = document.createElement('div');indicator.classList.add('indicator');if (i === 0) {indicator.classList.add('active-indicator');}indicatorContainer.appendChild(indicator);}}function nextImage() {currentIndex++;if (currentIndex >= images.length) {currentIndex = 0;}showImage(currentIndex);}function prevImage() {currentIndex--;if (currentIndex < 0) {currentIndex = images.length - 1;}showImage(currentIndex);}document.getElementById('next-btn').addEventListener('click', nextImage);document.getElementById('prev-btn').addEventListener('click', prevImage);// Auto-play functionalitysetInterval(nextImage, 2000);createIndicators();showImage(currentIndex);
</script>
</body>
</html>

 

 

 

http://www.hengruixuexiao.com/news/18873.html

相关文章:

  • 0基础多久学会网站架构网站及搜索引擎优化建议
  • 重庆璧山网站建设免费建站网站网页
  • 网站开发项目中的rd国内网络推广渠道
  • 选择适合的配色方案和风格宁波seo外包方案
  • 如何能让企业做网站的打算郑州制作网站公司
  • 商丘网络推广外包重庆seo建站
  • 山海关网站制作高明搜索seo
  • 温州专业营销网站公司百度搜索引擎优化方案
  • 域名和网站空间相互做解析网站秒收录工具
  • 优秀网站建设哪个公司好百度公司有哪些部门
  • 磁业 东莞网站建设企业品牌类网站有哪些
  • 合肥做个网站什么价格便宜网络推广外包公司
  • 网站浏览器测试深圳sem优化
  • bsci网站的cap是如何做网页设计期末作业模板
  • 好的网站建设商家做免费推广的平台
  • 惠州公司做网站深圳网站seo外包公司哪家好
  • 怎么做二维码让别人扫码进入网站外贸网络推广服务
  • wordpress 论坛风格重庆做优化的网络公司
  • 网站自己做还是用程序百度推广排名怎么做的
  • 丽水网站建设公司关键词林俊杰mp3下载
  • 中石化第五建设有限公司官方网站关键词优化精灵
  • 网站选服务器文件网站有吗免费的
  • 邢台手机网站制作百度搜索引擎官网入口
  • 泉州模板建站哪家好软文是什么意思通俗点
  • 重庆公积金门户网站seo就业指导
  • 如何做旅游休闲网站百度首页百度一下
  • 用vs做购物网站下载评论优化
  • 广州网站建设公司排名营销互联网推广公司
  • 做网站最小的字体是多少中国营销网站
  • 网站后台程序如何做百度新闻官网首页