ife-task0001暂存

<pre name="code" class="javascript"><pre name="code" class="html"><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/task0002_3.css">
	<script type="text/javascript" src="js/task0002_3.js" defer="defer"></script>	
	<title>task0002_3</title>
</head>
<body>
 	<div id="task3">
 		<span class="tip">任务3:轮播图</span>
 		<div id="contains">
 			<div id="img-wrap" style="left: 0px">
 				<img src="img/slide-1.png" alt="1">
 				<img src="img/slide-2.png" alt="2">
 				<img src="img/slide-3.png" alt="3">
 				<img src="img/slide-4.png" alt="4">
 				<img src="img/slide-5.png" alt="5">
 				<img src="img/slide-6.png" alt="6">
 			</div>
<div id="fp-nav">
 				<ul>
		 			<li class="light" index="0"><a href="#"></a></li>
		 			<li index="1"><a href="#"></a></li>
		 			<li index="2"><a href="#"></a></li>
		 			<li index="3"><a href="#"></a></li>
		 			<li index="4"><a href="#"></a></li>
	 			</ul>
 			</div>
	 		
 		</div>
 		<div id="setting">
 			<div class="order">				
 				<input type="radio" name="order" value="positive">正序</input>
 				<input type="radio" name="order" value="opposite">反序</input>
 			</div>
<div class="circle">
 				<input type="radio" name="circle" value="yes">循环</input>
 				<input type="radio" name="circle" value="No">单次</input>
 			</div>
 			<div class="time">
 				<input type="text" name="time" placeholder="请输入时间间隔" id="time">s</input>
 			</div>
			
			<div class="execute">
				<input type="button" name="btn" id="start" value="开始"></input>
				<input type="button" name="btn" id="stop" value="停止"></input>
			</div>	
 		</div>
 		
 	</div>

</body>
</html>



#task3 {
width: 980px;
margin: 20px auto;
}
#task3 span{
font-size: 1.2em;
font-weight: bold;
}


#contains {
width:600px;
height: 375px;
border: 1px solid black;
position: relative;
overflow: hidden;
}
 
#fp-nav {
<span style="white-space:pre">	</span>position: absolute;
<span style="white-space:pre">	</span>z-index: 2;
<span style="white-space:pre">	</span>top: 355px;
<span style="white-space:pre">	</span>left: 250px;
}




#fp-nav ul li{
 <span style="white-space:pre">	</span>width: 10px;
 <span style="white-space:pre">	</span>height: 10px;
 <span style="white-space:pre">	</span>color: white;
 <span style="white-space:pre">	</span>display:inline-block;
 <span style="white-space:pre">	</span>margin-right: 5px;
 <span style="white-space:pre">	</span>border: 2px solid #C0BDBD;
 <span style="white-space:pre">	</span>border-radius: 50%;
 <span style="white-space:pre">	</span>cursor: pointer;


}


#fp-nav ul .light {
<span style="white-space:pre">	</span>background: #976F6F;
}


#img-wrap {
<span style="white-space:pre">	</span>width: 3600px;
<span style="white-space:pre">	</span>font-size: 0px;
<span style="white-space:pre">	</span>z-index: -1;
<span style="white-space:pre">	</span>position:absolute;
}

#img-wrap img{
<span style="white-space:pre">	</span>width: 600px;
<span style="white-space:pre">	</span>display:inline-block;




}


#setting div {
<span style="white-space:pre">	</span>margin: 5px 0;
}


#setting div {
<span style="white-space:pre">	</span>color: #7470AC;
}
#setting .execute input{
<span style="white-space:pre">	</span>width: 50px;
<span style="white-space:pre">	</span>height: 20px;
<span style="white-space:pre">	</span>background: #D0D3E4;
<span style="white-space:pre">	</span>color: #BF8888;
<span style="white-space:pre">	</span>border-radius: 5px;
<span style="white-space:pre">	</span>border: 1px solid  #BAB4B4;
<span style="white-space:pre">	</span>margin-right: 30px;
<span style="white-space:pre">	</span>padding: 10px auto;
<span style="white-space:pre">	</span>cursor: pointer;
}


#setting .execute input:hover {
<span style="white-space:pre">	</span>background: #6C789B;
<span style="white-space:pre">	</span>color: white;
}

nction animate() {
	// 设置动画失效
	var isAnimate = false;	
	var dispSeq = 0;				//是否是正序
	var dispCircle = 0;				//是否循环	
	var dispTime = 2;				// 如果使用自动切换,该时间表示一张图片显示的时间

	// 取得fa-nav下的li标签
	var lis = document.getElementById("fp-nav").getElementsByTagName("li");
	// 获得显示图片的id
	var img = document.getElementById("img-wrap");
	var dispIndex = 0;				//	当前正显示的图片索引
	var timerHandler ;				// 自动播放时,定时器的句柄

	function showSel(sel) {
		// 先移除包含有light类名的对象, 然后根据sel对对象添加类名为light的类
		for (var i = 0; i < lis.length; i++) {
			if (lis[i].getAttribute("class") === "light") {
				lis[i].removeAttribute("class");
			}
		}
		// 添加类名为light的类
		lis[sel].setAttribute("class", "light");
	}
       function run(offset) {
		isAnimate = true;
		var newleft = parseInt(img.style.left) + offset;
		var speed = offset / (5);
		console.log("运行run函数")
		function go() {		 
			if (parseInt(img.style.left) != newleft) {
				img.style.left = parseInt(img.style.left) + speed + 'px';
				setTimeout(go, 50);
			} else {
				isAnimate = false;
				showSel(dispIndex);
				console.log("isAnimate = " + isAnimate);
			}
		}
		go();
	}
       // 添加手动移动照片
	function manualOperate() {
		for (var i = 0; i < lis.length; i++) {
			EventUtil.addHandler(lis[i], "click", function(){
				if (!isAnimate) {

					var toIndex = this.getAttribute("index");

					if (toIndex === dispIndex) {
						return ;
					}
					run((toIndex - dispIndex) * (-600));
					dispIndex = toIndex;

				}
			});
		}
	}
       // 获得参数
	function getParameter() {
		// 先清除正反序,和循环
		dispSeq = 0;
		dispCircle = 0;

		var order = document.getElementsByName("order");
		var circle = document.getElementsByName("circle");
		// 获得显示时间间隔
		dispTime = (document.getElementById("time").value > 0)?(document.getElementById("time").value):2;
		dispTime *= 1000;
		// 获得显示的正反序
		for (var i = 0; i < order.length; i++) {
			if (order[i].checked) {
				if (order[i].value == "positive") {
					dispSeq = -1;			// 正序
				} else if (order[i].value == "opposite") {	
					dispSeq = 1;			// 反序
				} 
			} 
		}
// 获得显示是否循环
		for (var i = 0; i < circle.length; i++) {
			if (circle[i].checked) {
				if (circle[i].value == "yes") {
					dispCircle = 1;				// 循环
				} else {
					dispCircle = 2;				// 不循环
				}
			}
		}
		
	}
	// 开始和停止
	function startAndStop() {
		var start = document.getElementById("start");
		var stop  = document.getElementById("stop");
// 添加开始按钮事件
		EventUtil.addHandler(start, "click", function() {
			var startKey = false;
			// 当点击开始时,先获取参数
			getParameter();			
			// 判断是否设置了参数
			if ((dispSeq != 0) && (dispCircle != 0) && (dispTime != 0)) {
				console.log("dispSeq = " + dispSeq);
				console.log("dispCircle = " + dispCircle);
				console.log("dispTime = " + dispTime);
				if (((dispSeq === -1) && (dispIndex === 4)) || 
					 ((dispSeq === 1) && (dispIndex === 0))) {
					startKey = true;
				} else {
					startKey = false;
				}
				// 只有当图片没有处于运行状态,按开始键才有效
				if (!isAnimate) {
					timerHandler = setInterval(function(){
						isAnimate = true;
 var offset;
						if (dispCircle === 1) {			// 循环
							if (dispSeq === -1) {			// 正序
								if (dispIndex === 4) {		// 到达边界
									offset = 2400;
									dispIndex = 0;
								} else {
									offset = -600;
									dispIndex++;
								}
							} else {						//反序
								if (dispIndex === 0) {		// 到达边界
									offset = -2400;
									dispIndex = 4;
								} else {
									offset = 600;
									dispIndex--;
								}
							}
						} else { 
if (dispSeq === -1) {			// 正序
								if (dispIndex === 4) {		// 到达边界
									if (startKey == true) {
										startKey = false;
										offset = 2400;
										dispIndex = 0;	
									} else {
										isAnimate = false;
										clearInterval(timerHandler);
										return ;
									}
								} else {
									offset = -600;
									dispIndex++;
									console.log(offset);
								}
							} else {
if (dispIndex === 0) {		// 到达边界
									if (startKey == true) {
										startKey = false;
										offset = -2400;
										dispIndex = 4;	
									} else {
										isAnimate = false;
										clearInterval(timerHandler);
										return ;
									}
								} else {
									offset = 600;
									dispIndex--;
								}
							}
						}
						run(offset);
					}, dispTime);
				}
			}
			// 没有设置参数,提示设置参数
			else {
				alert("请先设置参数")
			}
		});
		EventUtil.addHandler(stop, "click", function() {
			clearInterval(timerHandler);
		});
	}
	manualOperate();
	startAndStop();
}
window.onload = animate();


 
 
 

                
折叠面板是一个常见的 UI 组件,可以在 Web 页面上实现内容的展开与收缩。以下是一个 HTML 右边折叠面板的实现示例: HTML 代码: ```html <div class="panel-container"> <div class="panel-header"> <h3>折叠面板标题</h3> <span class="panel-arrow"></span> </div> <div class="panel-content"> <p>折叠面板内容</p> </div> </div> ``` CSS 代码: ```css .panel-container { position: relative; width: 400px; height: 100%; } .panel-header { position: relative; z-index: 1; height: 40px; background-color: #f0f0f0; border-bottom: 1px solid #d9d9d9; cursor: pointer; } .panel-header h3 { margin: 0; padding: 0 20px; line-height: 40px; font-size: 16px; font-weight: bold; color: #333; } .panel-arrow { position: absolute; top: 50%; right: 20px; width: 0; height: 0; margin-top: -5px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #999; transition: transform 0.3s ease; } .panel-content { position: absolute; top: 40px; right: 0; z-index: 0; width: 0; height: 0; overflow: hidden; background-color: #fff; transition: width 0.3s ease; } .panel-container.active .panel-header .panel-arrow { transform: rotate(180deg); } .panel-container.active .panel-content { width: 300px; height: 300px; } ``` 解释: 1. `.panel-container` 设置容器的宽度和高度,并设置为相对定位,以便内部元素进行定位。 2. `.panel-header` 设置折叠面板的标题栏样式,包括高度、背景色、边框和光标样式。 3. `.panel-header h3` 设置标题栏标题的样式,包括字体大小、颜色和粗细等。 4. `.panel-arrow` 设置标题栏右侧的箭头样式,包括定位、大小和颜色等。使用 `transition` 属性实现箭头旋转效果。 5. `.panel-content` 设置折叠面板的内容区样式,包括定位、大小、背景色和过渡效果等。使用 `overflow: hidden` 属性隐藏内容超出部分。 6. `.panel-container.active .panel-header .panel-arrow` 和 `.panel-container.active .panel-content` 通过 `.active` 类实现面板的展开和收缩效果。 以上是一个简单的 HTML 右边折叠面板的实现示例。可以根据实际需求调整样式和布局。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值