js无缝滚动效果几乎在任何网页上都能看到它的身影,有的可能是使用插件,其实使用原始的javascript比较简单。

主要的是使用js位置知识。

  • 1.innerHTML:设置或获取元素的html标签
  • 2.scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距
  • 3.offsetWidth:设置或获取指定标签的宽度
  • 4.setInterval():设置方法定时启动
  • 5.clearInterval();清除定时器

效果图:

js实现图片无缝滚动

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>javascript scroll制作</title>
</head>
<body>
<style>
  /*conment*/
  *{
  margin: 0;
  padding: 0;
 }
 img{max-width: 100%;}
 .container{
  max-width: 620px;
  margin: 0 auto;
  padding-top: 50px;
 }
 .text-center{text-align: center;}
 .list-inline li{
  display: inline-block;
 }
 .hide{display: none;}
 hr{
  margin:20px 0; 
 }
 .tag{
  background-color: #ccc;
  padding: 5px 0;
 }
 .tag li{
  padding: 0 10px;
  border-left: 1px solid #fff;
  cursor:pointer;
 }
 .tag li:first-child{
  border-left: transparent;
 }
 .tag li.active{
  background-color: #ddd;
 }
 .scroll{
  position: relative;
  padding: 10px;
  margin-bottom: 20px;
  background-color: #ddd;
 }
 .wrap{
  overflow: hidden; 
 }
 .content{
  min-width: 3000px;
  height: 200px;
 }
 .content ul{
  float: left;
 }
 .content ul li{
  display: inline-block;
  max-width: 200px;
 }
 #prev,#next{
  width: 50px;
  height: 50px; 
  margin-top: -25px; 
  background-color: #ccc; 
  line-height: 50px; 
  text-align: center;
  cursor: pointer; 
 }
 #prev{
  position: absolute;
  left: 0;
  top:50%;
  border-radius: 0 25px 25px 0;
 }
 #next{
  position: absolute;
  right: 0;
  top:50%; 
  border-radius: 25px 0 0 25px;
 }
</style>
  <div class="container">
    <h1 class="text-center">图片滚动制作</h1>
    <hr>
  <div class="scroll">
   <div class="wrap" id="wrap">
    <div id="content" class="content" >
     <ul id="list1">
      <li> <img src="/UploadFiles/2021-04-02/freelance.gif">

以上就是为大家分享的js实现图片无缝滚动代码,希望对大家的学习javascript程序设计有所帮助。

风云阁资源网 Design By www.bgabc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
风云阁资源网 Design By www.bgabc.com

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?