html如何实现简单酷炫的简单的渐变轮播插件呢?这篇文章能够教你!感兴趣的话请看下文。

话不多说,请看代码:

Example

.CreabineCarousel{

width: 100%;

height: 700px;

background-size: cover;

position: relative;

}

.CreabineCarousel .CreabineCarousel-dotContainer{

position:absolute;

bottom: 5%;

margin:0 auto;

z-index: 100;

list-style-type: none;

width: 100%;

text-align: center;

left: 0;

padding: 0;

}

.CreabineCarousel .CreabineCarousel-dotContainer .dot{

width: 30px;

height: 4px;

border-radius:3px;

background-color:#fff;

display: inline-block;

margin:0 5px;

opacity: 0.7;

}

.CreabineCarousel .CreabineCarousel-dotContainer .dot:hover{

opacity: 1;

}

.CreabineCarousel .CreabineCarousel-item{

position:absolute;

width: 100%;

height: 100%;

transition:all 0.8s;

}

.CreabineCarousel .CreabineCarousel-item h1{

max-width: 600px;

text-align: center;

font-size: 5rem;

line-height: 1.3;

color: #fff;

padding: 300px 50px 0 50px;

margin:0 auto;

}

.CreabineCarousel .CreabineCarousel-item p{

max-width: 600px;

text-align: center;

font-size: 1.4rem;

line-height: 1.4;

color: #fff;

padding-top: 10px 50px 0 50px;

margin:0 auto;

}

function CreabineCarousel(options){

var imgPathList = options.images;

var textList = options.contant;

if (!options.root) {

throw "require root to this CreabineCarousel";

}

if (!imgPathList) {

throw "must provide parameter images";

}

if (imgPathList.length != textList.length) {

throw "images are not equal to contants";

}

var changeCount = 0;

var timer;

var _autoScroll = options.autoScroll || false;

var _scrollDuration = options.scrollDuration || 4000;

var _height = options.height || 700;

function initElements() {

var _root = document.getElementById(options.root);

if (!_root) {

throw "no exist called this name element,please create element called this name";

}

_root.className = "CreabineCarousel";

_root.style.height = _height + "px";

var _dotContainer = document.createElement("ul");

_dotContainer.className = 'CreabineCarousel-dotContainer';

_root.appendChild(_dotContainer);

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

var _dot = document.createElement("li");

_dot.className = "dot";

_dot.id = "item" + (i+1) + "dot";

_dotContainer.appendChild(_dot);

var _item = document.createElement("div");

_item.className = "CreabineCarousel-item"

_item.id = "item" + (i+1);

_item.style.backgroundImage = "url(" + imgPathList[i] + ")";

_item.style.backgroundSize = "cover";

_item.style.backgroundRepeat = "no-repeat";

if(i == 0){

_item.style.opacity = '0';

_item.style.zIndex = '1';

}

_root.appendChild(_item);

var _h = document.createElement("h1");

_h.innerText = textList[i].title;

_item.appendChild(_h);

var _p = document.createElement("p");

_p.innerText = textList[i].text;

_item.appendChild(_p);

}

_dotContainer.addEventListener("mouseover",function(e){

if( e.target && e.target.className == "dot" ){

clearInterval(timer);

var id = e.target.id.substring(0,5);

CarouselHover(id);

}

});

_dotContainer.addEventListener("mouseout",function(e){

if( e.target && e.target.className == "dot" ){

var id = e.target.id;

CarouselOut(id);

}

});

if(_autoScroll){

timer = setInterval(function(){Carousel()},_scrollDuration);

}

}

function Carousel(){

var all = document.getElementsByClassName('CreabineCarousel-item');

for (var i = all.length - 1; i >= 0; i--) {

all[i].style.opacity = '0';

all[i].style.zIndex = '1';

}

var i=((changeCount++%5)+1);

var id = "item" + i;

document.getElementById(id)。style.opacity = '1';

document.getElementById(id)。style.zIndex = '10';

}

function CarouselHover(id){

clearInterval(timer);

var all = document.getElementsByClassName('CreabineCarousel-item');

for (var i = all.length - 1; i >= 0; i--) {

all[i].style.opacity = '0';

all[i].style.zIndex = '1';

}

document.getElementById(id)。style.opacity = '1';

document.getElementById(id)。style.zIndex = '10';

}

function CarouselOut(id){

var num = id.substring(4,5);

num = parseInt(num)-1;

changeCount = num;

timer = window.setInterval(function(){Carousel()},_scrollDuration);

}

initElements();

new CreabineCarousel({

root:'carouselRoot',

autoScroll:true,

scrollDuration:3000,

height:700,

images:['https://cdn.worktile.com/images/index/index_all_bg_1.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_2.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_3.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_4.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_5.jpg?v=4.5.18'],

contant:[

{

title:"title-1",

text:"text-111"

},

{

title:"title-2",

text:"text-222"

},

{

title:"title-3",

text:"text-333"

},

{

title:"title-4",

text:"text-444"

},

{

title:"title-5",

text:"text-555"

},

]

});

html渐变轮播,html简单的渐变轮播插件相关推荐

  1. android 图片轮播圆点,简单的图片轮播 加小圆点

    先说一下思路,使用ViewPager加 LinearLayout  布局 共同实现, 先看布局 android:layout_width="match_parent" androi ...

  2. 网页制作使用CSS样式制作轮播教程,静态网页设计与开发 1.案例——CSS3制作图片轮播图 (4)使用纯CSS3代码实现简单的图片轮播——分步骤实现.docx...

    使用纯CSS3代码实现简单的图片轮播 设计思路: 以5张图片为例: 1.基本布局: 通过设置每张图片的尺寸和父容器的尺寸,从而将5张图片横向并排放入一个div容器(#photos)内.所有图片设置统一 ...

  3. pc端html轮播带滑块,swiper.js简单快速实现轮播滑动(兼容PC端、移动端)

    swiper是一款免费以及轻量级轮播滑动的js框架,适用于PC端跟移动端,官方地址:(https://www.swiper.com.cn/) 效果演示: PC端 移动端(在浏览器将设备切换为手机,这里 ...

  4. android的颜色渐变动画效果图,Android简单实现一个颜色渐变的ProgressBar

    今天看一个教程,看到一个颜色渐变的ProgressBar,觉得有点意思,所以记录一番. 下面这个是效果图 颜色渐变的ProgressBar 看到效果图可能会给人一种使用了高端技术的感觉,其实这个没有那 ...

  5. jQuery实现简单图片的轮播(自右向左播放)

    简单的轮播大概内容分为如下三点: 1.轮播图片的存储: 2.轮播的样式(注意:图片存储的总宽度,以及图片移动相对元素的定位的元素): 3.JQuery中的计时器调用动画移动图片轮播. 一.carous ...

  6. 纯css自动全屏轮播图html代码,纯CSS3代码实现简单的图片轮播

    以4张图片为例: 1.基本布局: 将4张图片左浮动横向并排放入一个div容器内,图片设置统一尺寸,div宽度设置4个图片的总尺寸,然后放入相框容器div, 相框设置1个图片的大小并设置溢出隐藏,以保证 ...

  7. 老徐WEB:最简单详细的轮播图原理和制作过程(一)

    老徐利用空闲时间,制作了一个最简单的轮播图,主要介绍轮播图的原理和制作过程,只要大家能认真看完这篇文章,并理解文中内容,就能完全掌握轮播图的制作了.之后工作中碰到复杂的轮播图,自己也能思考制作出来了. ...

  8. html js简单实现图片轮播功能

    本章记录简单的图片轮播功能,需要html.js和css共同实现1.html文件 <!DOCTYPE html> <html><head><meta chars ...

  9. HTML网页js超简单实现图片轮播

    其实实现图片轮播很简单 1. 创建一个js文件(自己会的博主不多说) 2. 在html文件引入js文件 引入代码: <script type="text/javascript" ...

最新文章

  1. **极光推送PHP服务器端推送移动设备消息(Jpush V2 api)
  2. APK Expansion Files / Obb 接入介绍
  3. ubuntu下MySQL的安装
  4. Oracle数据库在.net连接问题总结
  5. Python狼人之夜--文字冒险游戏
  6. 学计算机专业选择设计为类需要艺考,想学设计必须参加艺考吗?设计学类专业,新高考选科怎么选?...
  7. 【OEIS】Xor Sum AtCoder2272
  8. 常见的几种最优化方法总结
  9. OpenCV图像处理--opencv摄像头播放视频
  10. 规划资源管理常用表格
  11. Chrome OS Factory开发测试流程
  12. Angular cdk 学习之 drag-drop
  13. 计算机锁屏打不开,电脑点锁屏锁不了怎么办
  14. 下雨天,走一段路,是走淋雨少还是跑
  15. 裁判文书网爬虫Docid解密思路
  16. 马云除了发20亿玩红包,支付宝还干了一件轰动全球的大事儿!
  17. 智能家居项目(八)之树莓派+摄像头进行人脸识别
  18. java如何设置jlabel位置_Java Swing – JLabel位置
  19. 【小经验】Windows 11 家庭中文版连接远程桌面,出现身份验证错误。要求的函数不受支持
  20. 用Python设计抢红包系统

热门文章

  1. 3dmax:3dmax三维VR渲染设置(VR发光贴图、VR灯光缓存、V-Ray焦散,渲染图中出现黑斑点的原因、插值类型)之详细攻略
  2. 敏捷开发之XP极限编程
  3. 如何区别劳动合同和劳务派遣合同
  4. Android应用市场平台应用认领
  5. 数据可视化之美 -- 以Matlab、Python为工具
  6. 网站服务器 64位,如何将win7系统从32位升级到64位_网站服务器运行维护,win7,32位,64位...
  7. BOOST升压电路参数计算
  8. 手把手教你如何在广交会使用OBS直播丨汇信外贸软件
  9. java.io.InvalidClassException:CartonPrintVO; local class incompatible: stream classdesc serialVersio
  10. php 豆瓣api_豆瓣的账号登录及PHP api操作