“正在加载,请稍后...”的实现方法

本文介绍了一种使用CSS和JavaScript创建加载提示效果的方法。通过添加自定义的遮罩层和消息提示,可以在页面上显示‘正在处理,请稍候...’的消息,并在处理完成后移除该提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 .datagrid-mask{
		position:absolute;
		left:0;
		top:0;
		width:100%;
		height:100%;
		background:#ccc;
		opacity:0.3;
		filter:alpha(opacity=30);
		display:none;
	}
	.datagrid-mask-msg{
		position:absolute;
		top:50%;
		margin-top:-20px;
		width:auto;
		height:16px;
		padding:12px 5px 10px 30px;
		/* background:#fff url('img/pagination_loading.gif') no-repeat scroll 5px 10px;
		border:2px solid #6593CF; */
		color:#222;
		display:none;
	}

如下是js代码添加div,之后直接调用就可以了,第一个方法时显示样式,第二个方法时执行完了后去掉这个样式。

function AddRunningDiv() {
            $("<div class=\"datagrid-mask\"></div>").css({ display: "block", width: "100%", height: $(document).height() }).appendTo("body");
            $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候...").appendTo("body").css({ display: "block", left: ($(document.body).outerWidth(true) - 190) / 2, top: ($(document).height() - 380)});
        } 
    	function MoveRunningDiv() {
            $("div[class='datagrid-mask']").remove();
            $("div[class='datagrid-mask-msg']").remove();
        }  


要在HTML中创建一个带有动态球体的加载页面,并显示“正在进入系统,稍后...”,你可以使用HTML、CSS 和 JavaScript 来完成这个效果。下面是一个简单的例子: ### HTML 文件内容 ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>加载页面</title> <style> body { margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: transparent; /* 设置背景为透明 */ font-family: Arial, sans-serif; position: relative; } .loader-container { text-align: center; z-index: 1; } h1 { color: #ffffff; opacity: 0.95; margin-bottom: 20px; } .balls { width: 100%; max-width: 400px; margin: auto; overflow: hidden; } @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } } .ball { float: left; margin-right: 10px; border-radius: 50%; animation-name: bounce; animation-duration: 1s; animation-timing-function: ease-in-out; animation-iteration-count: infinite; } .ball:nth-child(1) { width: 10px; height: 10px; background-color: rgb(67, 160, 71); animation-delay: -0.3s; } .ball:nth-child(2) { width: 20px; height: 20px; background-color: rgba(67, 160, 71, 0.8); animation-delay: -0.2s; } .ball:nth-child(3) { width: 30px; height: 30px; background-color: rgba(67, 160, 71, 0.6); animation-delay: -0.1s; } .ball:nth-child(4) { width: 40px; height: 40px; background-color: rgba(67, 160, 71, 0.4); } </style> </head> <body> <div class="loader-container"> <h1>正在进入系统,稍后...</h1> <div class="balls"> <span class="ball"></span> <span class="ball"></span> <span class="ball"></span> <span class="ball"></span> </div> </div> </body> </html> ``` #### 解释代码功能: - `body` 元素设置了全屏居中的布局并保持了透明背景。 - 使用 `.loader-container` 包裹文本信息,使其位于屏幕中央。 - 定义了一个名为`.balls` 的容器用于放置动画小球们;每个小球通过自定义样式来改变尺寸及颜色深浅度,同时利用 CSS 动画实现上下跳动的效果。 此代码会生成一段有四个不同大小的绿色半透明圆点,在页面中心位置不断跳跃,旁边则有一行提示文字说明当前处于等待状态。如果你想要调整球的颜色或者其他属性的话可以直接修改对应的css规则即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值