通用遮盖层,即遮罩层,简单实用

<div id="cover" style="display: none;">
</div>

$("#cover").css({ left:0, top: 0, height: "100%", width: "100%", position: "fixed", "background-color": 'black', "z-index": 999, opacity: 0.7, display: "block" });

$("#cover").css({ left:0, top: 0, right:0, bottom:0, position: "fixed", "background-color": 'black', "z-index": 999, opacity: 0.7, display: "block" });

//上面的遮罩层完善如下:

<html>
<head>
<style type="text/css">
#loading{
width:100%;
height: 100%;
position:fixed;
top: 0;
left: 0;
background-color: black;
z-index: 999;
opacity: 0.6;
display: none;
}

#loading img {
width: 50px;
height: 50px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -25px; /* 高度的一半 */
margin-left: -25px; /* 宽度的一半 */
}

</style>
<script src='jquery-1.8.2.min.js'></script>
<script type='text/javascript'>
function showpop()
{
$("#loading").toggle();
}
</script>
</head>
<body>
<div id="loading">
<img src="loading.gif" alt="loading">
</div>
<input type="button" id='btn' value='click me' onclick="showpop()">
</body>
</html>

//文本框字数限制示例:

<div class="edit-text">
                    <textarea id="txtUserText" placeholder="写下你此刻的想法……"></textarea>
                    <div class="edit-technology"><span id="text-count">0</span>/100</div>
                </div>

$("#txtUserText").on("input propertychange", function () {
                var $this = $(this),
                    _val = $this.val(),
                    count = "";
                if (_val.length > 100) {
                    $this.val(_val.substring(0, 100));
                }
                count = $this.val().length;
                $("#text-count").text(count);
            });

posted on   itjeff  阅读(363)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2017-02-08 C# 使用Nlog记录日志到数据库
2014-02-08 什么是工厂模式

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示