博主信息
博文 35
粉丝 2
评论 0
访问量 27443
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
选项卡和自动聊天机器人--2018年4月2日17时30分
小学僧的博客
原创
755人浏览过

一、以下是选项卡代码:

可以根据鼠标停留不同位置显示不同的内容,

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.box{
			width: 100%;
			height: 150px;
			margin:auto;
			font-family: microsoft yahei;
			background-color: #F8F8FF;
		}
		.box .bar{
			width: 1000px;
			height: 75px;
			/*background-color: lightgray;*/
			margin:auto;
		}
		.box .bar ul{
			margin: 0;
			padding: 0;
			overflow: hidden;
			margin: auto;
			display: table;
			text-align: center;
		}
		.box .bar ul li{
			color: #000;
			list-style-type: none;			
			width: 83px;
			height: 100%;
			padding:0 5px;
			/*background-color: gray;*/
			float: left;
			line-height: 75px;
		}
		.box .bar ul li:first-child{		
			width: 60px;
		}
		.box .bar ul li.actived{
			background-color: red;
			cursor: pointer;
			color: #fff;
		}
		.box .sbar div{
			width: 1000px;
			height: 60px;
			/*background-color: lightgray;*/
			margin: auto;
			display:none
		}
		.box .sbar  ul{
			padding: 0;
			margin: 0;
			/*width: 300px;*/
			overflow: hidden;
			margin: auto;
			display: table;
			text-align: center;
			background-color: #4a4c4f;
		}
		.box .sbar ul li{
			color: #DCDCDC;
			font-size: 14px;
			list-style-type: none;
			float: left;
			width: 70px;
			height: 100%;
			line-height: 60px;		
		}
		.box .sbar ul li:hover{
			color:#CD5C5C;
			cursor: pointer;
		}
		.box  .sbar .sbar1 ul{
			margin-left: 303px;
		}
		.box  .sbar .sbar2 ul{
			margin-left: 395px;
		}
		.box  .sbar .sbar3 ul{
			margin-left: 489px;
		}
		.box  .sbar .sbar4 ul{
			margin-left: 581px;
		}
		.box  .sbar .sbar5 ul{
			margin-left: 674px;
		}
	</style>
</head>
<body>
	<div class="box">
		<div class="bar" >
			<ul>
				<li class="actived">首页</li>
				<li>公司集团</li>
				<li>新闻中心</li>
				<li>产品系列</li>
				<li>投资关系</li>
				<li>客户服务</li>
			</ul>
		</div>
		<div class="sbar">
			<div style="height: 0"></div>
			<div class="sbar1" >			
				<ul>
					<li>集团介绍</li>
					<li>团队介绍</li>
					<li>企业荣誉</li>
				</ul>			
			</div>
			<div class="sbar2" >			
				<ul>
					<li>集团新闻</li>
					<li>地方动态</li>
					<li>媒体报道</li>
				</ul>			
			</div>
			<div class="sbar3" >			
				<ul>
					<li>产品系列1</li>
					<li>产品系列2</li>
					<li>产品系列3</li>
					<li>产品系列4</li>
				</ul>			
			</div>
			<div class="sbar4" >			
				<ul>
					<li>最新公告</li>
					<li>投资信息</li>
				</ul>			
			</div>
			<div class="sbar5" >			
				<ul>
					<li>服务理念</li>
					<li>服务宗旨</li>
					<li>联系方式</li>
				</ul>			
			</div>
		</div>		
	</div>
</body>
</html>
<script type="text/javascript">
	var  bar = document.getElementsByClassName('bar')[0]
	var  ul = bar.getElementsByTagName('ul')[0]
	var  li = ul.getElementsByTagName('li')
	var  sbar = document.getElementsByClassName('sbar')[0]
	var  div = sbar.getElementsByTagName('div')
	li[0].className = ''
	for(var i=0;i<6;i++){
		li[i].index = i;
		div[i].index = i;
		li[i].onmouseover = function(){
			for(var i=0;i<6;i++){
				li[i].className = ''
				div[i].style.display = 'none'
			}
		this.className = 'actived'
		div[this.index].style.display = 'block'		
		}		
	}	
</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例

二、机器聊天代码:

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>聊天窗口</title>
	<style type="text/css">
	body{
		font-family: microsoft yahei;
	}
		div:nth-child(1) {
			width: 450px;
			height: 550px;
			background-color: #F5F5F5;
			margin: 10px auto;
			color: #333;
			box-shadow: 2px 2px 2px gray;
			border-radius: 5px;

		}		
		h2 {
			font-size: 18px;
			text-align: center;
			margin-bottom: -5px;
			padding-top: 10px;
		}
		div:nth-child(2) {
			width: 380px;
			height: 400px;
			border: 3px double #1E90FF;
			border-radius: 5px;
			background-color: #efefef;
			margin: 20px auto 10px;
		}
		
		ul {
			list-style: none;
			line-height: 2em;
			overflow: hidden;
			padding: 15px;
		}

		table {
			width: 90%;
			height:80px;
			margin: auto;
		}

		textarea{
			border: none;
			resize: none;
			background-color: #ADD8E6;
			margin-left: 10px;
			
		}
		button {
			width: 50px;
			height: 62px;
			background-color: #1E90FF;
			color: #fff;
			border-radius: 3px;
			border: none;
		}
		button:hover {
			cursor: pointer;
			opacity: 0.8;
		}
	</style>
</head>
<body>
	<div>
		<h2>在线客服</h2>
		<div contenteditable="true">
			<ul>
				<li></li>
			</ul>
		</div>
		<table>
			<tr>
				<td align="right"><textarea cols="45" rows="4" name="text"></textarea></td>
				<td align="left"><button type=button>Send</button></td>
			</tr>
		</table>	
	</div>
	<script type="text/javascript">
		var btn = document.getElementsByTagName('button')[0]
		var text = document.getElementsByName('text')[0]
		var list = document.getElementsByTagName('ul')[0]
		var sum = 0

		btn.onclick = function () {
			if (text.value.length == 0) {
				alert('input is null!')
				return false
			}
			var words = text.value
			 text.value = ''
			var li = document.createElement('li')			
			li.innerHTML = words
			var userPic = '<img src="../img/2.jpg" width="30" style="border-radius:50%">'
			li.innerHTML = userPic+'<span style="padding-left:10px;">'+words+'</span>'
			list.appendChild(li)
			sum += 1						
			setTimeout(function(){
				var info = ['test1','test2','test3']
				var temp = info[Math.floor(Math.random()*3)]			
				var reply = document.createElement('li')
				var Pic = '<img src="../img/1.jpg" width="30" style="border-radius:50%;">'				
				reply.innerHTML = Pic + '<span style="color:#1E90FF;padding-left:10px;">'+temp+'</span>'
				list.appendChild(reply)
				sum += 1
			},1500)						
			if (sum >8) {
				list.innerHTML = ''
				sum = 0
			}
		}
	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

三、手写代码:

211.jpg

12.jpg

四、总结

这次没有点评,没有详细总结,看见首页推荐的那些,有的代码直接ctrl+c/v,没有文字说明,学习他们

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学