元谋竟然下雪了 是冬负了雪 还是雪背叛了冬 你本该是冬的伴侣 却跑来做春的情人 人们该赞美你的热情奔放 还是该指责你的水性扬花 你若与冬同行 或许会更幸福美满些 因为冬用它的温度延长雪美丽的生命 而你在春的世界里漫天飞舞 即背叛了冬 也阻挡了春与雨的恋情 连雪都移情别恋 这个世界乱了。

<

图片轮播网页的制作

步骤:1、用word打开自己的网站中的“ymfj.htm”网页,删除顶端的“banner”图片,输入“元谋下雪了”回车后再输入位置标记“tp1”,保存退出。

 2、复制如下代码

      <!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html,
body {
margin: 0;
padding: 0;
}

ul {
list-style: none;
}

#slideshow {
width: 50vw;
height:50vh;

overflow: hidden;
position: relative;
margin: 0 auto;
}

#imglist li {
width:20%;
height: 20%;
position: absolute;
/* 全部图片设为透明 */
opacity: 0;
transition: opacity 5s;
}

#imglist>li img {
height:500px;
}

#dotlist {
position: absolute;
bottom: 30px;
width: 100px;
display: flex;
justify-content: space-between;
left: 50%;
transform: translate(-50%);
}

#dotlist>li {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: rgb(206, 16, 16);
/* 全部小圆点设为半透明 */
opacity: 0.3;
cursor: pointer;
user-select: none;
}
/* 具有appear类的元素设为 不透明 即显示 */

#imglist>li.appear,
#dotlist>li.appear {
opacity: 1;
}
/* 左右轮播按钮 */

#pre,
#next {
position: absolute;
font-size: 100px;
color: rgba(0, 0, 0, .3);
top: 50%;
transform: translate(0, -50%);
font-weight: bold;
cursor: pointer;
user-select: none;
}

#pre {
left: 20px;
}

#next {
right: 20px;
}

#pre:hover,
#next:hover {
color: rgba(255, 255, 255, .3);
}
</style>
</head>

<body>

<div id="slideshow">
<ul id="imglist">

 

<li><a href="https://imgtu.com/i/biTXWT"><img src="https://s4.ax1x.com/2022/02/24/biTXWT.md.jpg" alt="biTXWT.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/biTxlF"><img src="https://s4.ax1x.com/2022/02/24/biTxlF.md.jpg" alt="biTxlF.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/bi7SOJ"><img src="https://s4.ax1x.com/2022/02/24/bi7SOJ.md.jpg" alt="bi7SOJ.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/biTzy4"><img src="https://s4.ax1x.com/2022/02/24/biTzy4.md.jpg" alt="biTzy4.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/biTvSU"><img src="https://s4.ax1x.com/2022/02/24/biTvSU.md.jpg" alt="biTvSU.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/bi7FFx"><img src="https://s4.ax1x.com/2022/02/24/bi7FFx.md.jpg" alt="bi7FFx.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/bi79m9"><img src="https://s4.ax1x.com/2022/02/24/bi79m9.md.jpg" alt="bi79m9.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/bi7CwR"><img src="https://s4.ax1x.com/2022/02/24/bi7CwR.md.jpg" alt="bi7CwR.md.jpg" border="0"></a></li>
<li><a href="https://imgtu.com/i/bi7PT1"><img src="https://s4.ax1x.com/2022/02/24/bi7PT1.md.jpg" alt="bi7PT1.md.jpg" border="0"></a></li>

</ul>
<ul id="dotlist">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>

</ul>
<div id="pre">&lt;</div>
<div id="next">&gt;</div>
</div>
<script>
// 找对象
var slideShow = document.getElementById("slideshow");
var imgList = document.getElementById("imglist");
var imgs = imgList.children;
var dotList = document.getElementById("dotlist");
var dots = dotlist.children;
var pre = document.getElementById("pre");
var next = document.getElementById("next");
var duration = 5000; // 设置轮播时间间隔
var Index = 0;
var count = imglist.children.length; // 获取图片数量
var timer; // 设置一个计时器

window.onload = function() {
imgList.children[0].classList.add("appear"); // 初始时显示第一幅图片
dotList.children[0].classList.add("appear"); // 初始时第一个点为白色

//为每个点添加单击处理函数
for (var i = 0; i < dots.length; i++) {
dots[i].index = i;
dots[i].onclick = changeMe;
}

//启动动画自动播放
timer = setInterval(rotate, duration);

// 鼠标移到图片上面时,停止动画
slideShow.onmouseover = function(event) {
clearInterval(timer);
};

// 鼠标离开图片上面时,启动动画
slideShow.onmouseout = function(event) {
timer = setInterval(rotate, duration);
};

//左右播放图片
pre.onclick = preImg;
next.onclick = nextImg;
}

//改变图片和点的当前状态(通过 添加 或 移除 appear 属性)
function change() {
for (var i = 0; i < dots.length; i++) {
dots[i].classList.remove("appear");
imgs[i].classList.remove("appear");
}
dots[Index].classList.add("appear");
imgs[Index].classList.add("appear");
}

//循环切换图片
function rotate() {
Index++;
if (Index == count) {
Index = 0;
}
change();
}

//切换上一幅图片
function preImg() {
Index--;
if (Index < 0) {
Index = count - 1;
}
change();
}

//切换下一幅图片
function nextImg() {
Index++;
if (Index == count) {
Index = 0;
}
change();
}

//单击某个圆点,切换到相应图片
function changeMe() {
Index = this.index;
change();
}
</script>
</body>

</html>

 

3、用记事本打开“ymfj.htm”,编辑---查找---tp1,在tp1的后面“粘贴”代码。

4、修改代码

(1)slideshow (幻灯片大小)
width: 50vw;
height:50vh;

(2)、imglist li (图片透明度)
width:20%;
height: 20%;

(3)、imglist>li img (图片大小)
height:500px;

(4) var duration = 5000; // 设置轮播时间间隔(轮播间隔时间)

(5)<ul id="imglist"> (图片地址 )

(6)<ul id="dotlist">(圆点数)


 

 

2025促销:香港特价空间,最低仅需20元,可永久使用!
本站空间由 三维免费空间 友情提供