一个小HTML页面,不可拒绝

首先说明代码的含义
icon图标主页下载资源里
可自行修改内容和数据

  • 先搞一个div用来放按钮,
  • 设置div的背景颜色、边缘距离等样式,
  • 指定按钮设置js代码,随机改变位置
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="author"  content="理查德;1295634075@qq.com" />
		<link rel="shortcut icon" href="img/爱心.ico" type="image/x-icon" />
		<title>LOVE</title> 
		<style>
			#love1{
				/*初始div宽度高度*/
				width: 250px;
				height: 250px;
				/*文字居中*/
				text-align: center; 
				
				/*边框、背景颜色、盒子*/
				border-radius: 0px;
				background: #0f26d7;
				
             	/*div初始边缘距离*/		
             	margin-top: 200px;
             	margin-left: 600px;	
			}
			#love1 input{
				width: 50px;
				height: 50px;
				margin: 30px;
				border-radius: 41px;
				background: #e2121d;	
			}	
		</style>
		
		<script>
			// yes键
			function Fun_Yes() {
			// 尝试询问
				prompt("您真的爱我嘛?(爱or不爱)","不爱")
				
			}
			// no键
			function Fun_No(){
				var love = document.getElementById("love1");
				// 移动div,随机改变边缘距离   							 1000、500 根据显示器分辨率不同可修改数据
				var left = Math.floor(Math.random()*1000);
				var top = Math.floor(Math.random()*500);
				// 改变边缘距离
				love.style.marginTop=top+"px";
				love.style.marginLeft=left+"px";
			}
			
		</script>
	</head>
	<body>
		<div id="love1">
			<hr />
			<h2>
				<!--文本提示信息-->
				Do you <font style="color: red;">LOVE</font> me?
			</h2>
			<!--是,确定键-->
			<input type="button" value="Yes" onclick="Fun_Yes()" />
			<!--否,取消键-->
			<input type="button" value="No" onmouseover="Fun_No()" />
		</div>
	</body>
</html>

大概效果图:
触碰到 No 就会自动刷新并改变位置
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_苏歌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值