php js轮播图片代码,javascript实现焦点图轮播效果代码示例

本篇文章通过代码实例来给大家介绍一下javascript实现焦点图轮播效果。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

b5d07c221a550fc0175a808b85c7945d.png

JS实现焦点图轮播效果

效果图:

04e132727f1f011cc602ecd736322b0e.png

(不过里面的图片路径需要自己改成自己的图片路径,否则是没有图片显示的哦)

代码如下,复制即可使用:

JS实现焦点图轮播效果

* {

margin: 0;

padding: 0;

text-decoration: none;

}

body {

padding: 20px;

}

#container {

width: 600px;

height: 400px;

border: 3px solid #333;

overflow: hidden;

position: relative;

}

#list {

width: 4200px;

height: 400px;

position: absolute;

z-index: 1;

}

#list img {

float: left;

}

#buttons {

position: absolute;

height: 10px;

width: 100px;

z-index: 2;

bottom: 20px;

left: 250px;

}

#buttons span {

cursor: pointer;

float: left;

border: 1px solid #fff;

width: 10px;

height: 10px;

border-radius: 50%;

background: #333;

margin-right: 5px;

}

#buttons .on {

background: orangered;

}

.arrow {

cursor: pointer;

display: none;

line-height: 39px;

text-align: center;

font-size: 36px;

font-weight: bold;

width: 40px;

height: 40px;

position: absolute;

z-index: 2;

top: 180px;

background-color: RGBA(0, 0, 0, .3);

color: #fff;

}

.arrow:hover {

background-color: RGBA(0, 0, 0, .7);

}

#container:hover .arrow {

display: block;

}

#prev {

left: 20px;

}

#next {

right: 20px;

}

window.onload = function() {

var container = document.getElementById('container');

var list = document.getElementById('list');

var buttons = document.getElementById('buttons').getElementsByTagName('span');

var prev = document.getElementById('prev');

var next = document.getElementById('next');

var index = 1;

var len = 5;

var animated = false;

var interval = 3000;

var timer;

function animate(offset) {

if(offset == 0) {

return;

}

animated = true;

var time = 300;

var inteval = 10;

var speed = offset / (time / inteval);

var left = parseInt(list.style.left) + offset;

var go = function() {

if((speed > 0 && parseInt(list.style.left) < left) ||

(speed < 0 && parseInt(list.style.left) > left)) {

list.style.left = parseInt(list.style.left) + speed + 'px';

setTimeout(go, inteval);

} else {

list.style.left = left + 'px';

if(left > -200) {

list.style.left = -600 * len + 'px';

}

if(left < (-600 * len)) {

list.style.left = '-600px';

}

animated = false;

}

}

go();

}

function showButton() {

for(var i = 0; i < buttons.length; i++) {

if(buttons[i].className == 'on') {

buttons[i].className = '';

break;

}

}

buttons[index - 1].className = 'on';

}

function play() {

timer = setTimeout(function() {

next.onclick();

play();

}, interval);

}

function stop() {

clearTimeout(timer);

}

next.onclick = function() {

if(animated) {

return;

}

if(index == 5) {

index = 1;

} else {

index += 1;

}

animate(-600);

showButton();

}

prev.onclick = function() {

if(animated) {

return;

}

if(index == 1) {

index = 5;

} else {

index -= 1;

}

animate(600);

showButton();

}

for(var i = 0; i < buttons.length; i++) {

buttons[i].onclick = function() {

if(animated) {

return;

}

if(this.className == 'on') {

return;

}

var myIndex = parseInt(this.getAttribute('index'));

var offset = -600 * (myIndex - index);

animate(offset);

index = myIndex;

showButton();

}

}

container.onmouseover = stop;

container.onmouseout = play;

play();

}

1

1

2

3

4

5

5

更多炫酷CSS3、html5、javascript特效代码,尽在:js特效大全

### 关于面包板电源模块 MB102 的 USB 供电规格及兼容性 #### 1. **MB102 基本功能** 面包板电源模块 MB102 是一种常见的实验工具,主要用于为基于面包板的小型电子项目提供稳定的电压输出。它通常具有两路独立的稳压输出:一路为 5V 和另一路可调电压(一般范围为 3V 至 12V)。这种设计使得它可以满足多种芯片和传感器的不同工作电压需求。 #### 2. **USB 供电方式** MB102 支持通过 USB 接口供电,输入电压通常是标准的 5V DC[^1]。由于其内部集成了 LM7805 稳压器以及可调节电位器控制的直流-直流变换电路,因此即使输入来自电脑或其他低功率 USB 设备,也能稳定地向负载供应电力。不过需要注意的是,如果项目的功耗较高,则可能超出某些 USB 端口的最大电流能力(一般是 500mA),从而引起不稳定现象或者保护机制启动断开连接的情况发生。 #### 3. **兼容性分析** 该型号广泛适用于各种微控制器单元 (MCU),特别是那些像 Wemos D1 R32 这样可以通过杜邦线轻松接入并共享相同逻辑级别的系统[^2]。另外,在提到 Arduino Uno 板时也表明了良好的互操作性,因为两者均采用相似的标准接口定义与电气特性参数设置[^4]: - 对于需要 3.3V 工作环境下的组件来说,只需调整好对应跳线帽位置即可实现精准匹配; - 当涉及到更多外围扩展应用场合下,例如带有多重模拟信号采集任务的情形里,利用 MB102 提供干净无干扰的基础能源供给就显得尤为重要了[^3]。 综上所述,对于打算构建以单片机为核心的原型验证平台而言,选用具备良好声誉记录且易于获取配件支持服务链路上下游资源丰富的品牌产品——如这里讨论过的这款特定类型的配电装置不失为明智之举之一。 ```python # 示例 Python 代码展示如何检测硬件状态 import machine pin = machine.Pin(2, machine.Pin.IN) if pin.value() == 1: print("Power supply is stable.") else: print("Check your connections and power source.") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值