大型项目必备登录框

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>登录框</title>
	<style>
		html,body {
			height: 100%;
			overflow: hidden;
			margin: 0 auto;

		}
		body {
			display: flex;
			justify-content: center;
			align-items: center;
			background-image: url('./one.jpg');
			background-size: 100% 100%;
			background-repeat: no-repeat;

		}
		div {
			width: 60%;
			height: 300px;
			border: 1px solid #ccc;
			border-radius: 3em;
			overflow: hidden;
		}
		input {
			display: block;
			/*px是像素单位,em是文字大小单位,1em=1个字体的大小*/
			height: 2em;
			width: 50%;
			font-size: 20px;
			/*margin作用与块级元素,对于行内元素无效果*/
			margin: 1em auto;
			background-color: #ddd;
			color: #fff;
			border-radius: 3em;
			border: 0;
			outline: none;


		}
		input:focus {
			width: 80%;
			transition: all 2s;
		}
		h1 {
			/*h1是块级元素,里面的内容是行内元素。*/
			/*设置子元素的对齐方式*/
			text-align: center;
			line-height: 2em;
			margin: 0 auto;
			width: 3em;
			
		}
		div:hover h1 {
			width: 100%;
			color: #fff;
			background-color: rgba(0,0,0,.5);
			transition: all 0.54s;

		}
		
		
	</style>
</head>
<body>
	<div>
		<h1>login</h1>
		<form method="get" action="https://aiowo.cn/login.php">
			<input id="user" class="user" name="user" type="text">
			<input id="pwd" class="pwd" name="pwd" type="password">
			<input id="btn" type="submit" name="" value="提交">
		</form>
	</div>
	<!-- 表单验证 -->
	 <!-- javascript 验证表单 -->
	<script>
		// 阻止表单默认跳转 绑定监听
		document.getElementById('btn').addEventListener('click', 
			(e) => {
				if(login()){
					// 阻止默认跳转
					e.preventDefault();
				}
				
			},false);

		function login(){
			if(user.value=='' || pwd.value==''){
				alert('请输入完整信息');
				return 1;
			}
			else {
				return 0;
			}
		}

	</script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值