国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

原生JS實現的簡單輪播圖功能【適合新手】

2024-05-06 16:45:44
字體:
來源:轉載
供稿:網友

本文實例講述了原生JS實現的簡單輪播圖功能。分享給大家供大家參考,具體如下:

經過幾天的努力,終于攻克了這一難題,于是迫不及待的想要分享給大家,編寫之前,我也看了不少其他博主的博客,大多是用偏移量寫的,對新手來說,還是有些難以理解,雖然可能實現的需求不一樣,但我想先從簡入手,所以自己查閱資料,修改bug,終于完成。話不多說,上代碼:

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>www.survivalescaperooms.com JS輪播圖</title><script src="jquery.js"></script><style>*{margin: 0px;padding:0px;list-style: none;text-decoration: none;}#flash{ /*根據圖片的大小來設置外層div的大小*/width: 520px;height: 280px;margin: 0 auto;position: relative; /*設置div定位,方便之后圖片及圓點位置的設定*/border:1px solid black;}#flash img{width: 100%;height: 100%;position: absolute; /*設置所有圖片重疊*/left: 0px;top: 0px;display: none; /*設置所有圖片隱藏,通過改變第一個圖片的行間樣式來使第一個圖片顯示*/}#flash ul{width: 150px;height: 25px;border-radius: 20px;background-color:rgba(255,255,255,0.5);position: absolute;left: 35%;bottom: 10%;}#flash ul li{width: 12px;height: 12px;margin-top:5px;background-color: #fff;border-radius: 50%;margin-left: 15px;float: left;}#flash ul .li_1{background-color: #f40; /*設置第一個圓點背景色為紅色*/}#flash .span-r{width: 50px;height: 50px;border-radius: 50%;position: absolute;right: 2%;top: 45%;background-color: rgba(255,255,255,0.5);}#flash .span-r span{width: 100%;height:100%;color:rgba(0,0,0,0.5);font-size: xx-large;font-weight: 700;line-height: 50px;margin-left: 15px;cursor: pointer;}#flash .span-l{width: 50px;height: 50px;border-radius: 50%;position: absolute;left: 2%;top: 45%;background-color: rgba(255,255,255,0.5);}#flash .span-l span{width: 100%;height:100%;color:rgba(0,0,0,0.5);font-size: xx-large;font-weight: 700;line-height: 50px;margin-left: 15px;cursor: pointer;}</style></head><div id="flash"><img src="http://demo.vevb.com/js/2018/html5-css3-3d-img-flash-codes/images/Guardians-of-the-Galaxy-Poster-High-Res.jpg" src="/uploads/allimg/180819/104J544U-0.jpg" style="border: 1px solid rgb(204, 204, 204); vertical-align: middle; padding: 1px; overflow: hidden; max-width: 650px;" />

感興趣的朋友可以自己動手測試一下。

希望本文所述對大家JavaScript程序設計有所幫助。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德保县| 苍山县| 确山县| 屏边| 肇庆市| 龙陵县| 仪陇县| 太湖县| 于都县| 昭觉县| 高碑店市| 新干县| 福安市| 合山市| 瑞丽市| 上饶县| 临西县| 红原县| 泌阳县| 太仆寺旗| 靖安县| 顺平县| 永平县| 花莲县| 浦东新区| 阿坝| 禹城市| 滦平县| 措勤县| 昭通市| 昂仁县| 巴楚县| 涪陵区| 碌曲县| 交口县| 镇巴县| 双辽市| 华容县| 南华县| 贵定县| 达拉特旗|