jquery模拟手机聊天操作

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			#box{
				width: 300px;
				height: 500px;
				border: 3px solid lightgray;
				margin: 0 auto;
				position: relative;
				overflow: hidden;
			}
			#one{
				width: 100%;
				height: 50px;
				border-top: 2px solid lightgray;
				position: absolute;
				bottom: 0;
				left: 0;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
			}
			span{
				display: block;
				background: red;
				margin-right: 3px;
			}
			#o1{
				flex: 1;
			}
			#o2{
				flex: 4;
			}
			#o3{
				flex: 1;
			}
			input{
				margin-top: 3px;
				margin-left: 3px;
				width: 92%;
				height: 35px;
			}
			#btn{
				width: 100%;
				height:100%;
				text-align: center;
			}
			.left{
				width: 100px;
				height: 65px;
				float: left;
				clear: both;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
			}
			.right{
				width: 100px;
				height: 65px;
				float: right;
				clear: both;
			}
		</style>
		<script src="jquery-3.4.1.min.js"></script>
	</head>
	<body>
		<div id="box">
			<div id="oo">
				
			</div>
			<div id="one">
				<span id="o1">
					<img src="img/1.png" width="50px" height="50px">
				</span>
				<span id="o2">
					<input type="text" id="text1">
				</span>
				<span id="o3">
					<button id="btn">发送</button>
				</span>
			</div>
		</div>
		<script type="text/javascript">
			$(function(){
				$('#btn').click(function(){
					var div=$('<div>');
					div.addClass('left');
					var img=$("<img src='img/1.png' width='40px' height='40px'>");
					div.append(img);
					var span=$('<span>');
					span.css({
						'width':'75px',
						'height':'45px',
						'background':'lightgray'
					})
					span.html($('#text1').val());
					div.append(span);
					$('#oo').append(div);
					// div.next().addClass('right');
				})
			})
		</script>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值