CSS模拟实现alert和confirm实现_html/css_WEB-ITnose
由于原生的alert和confirm在不同手机上显示样式不一样,而且也难看。所以用css模拟了原生的alert和confirm实现。
具体代码如下:
<!DOCTYPE html><html><head><title>confirm和alert的demo</title><meta charset="UTF-8"><script src="jquery.min.js"></script><style type="text/css">/*w-error-popup-white*/.w-error-popup-white{ width: 100%; height: 100%; z-index: 999; position: fixed; left: 0; top:0;}.w-error-popup-white .w-error-back{ width: 100%; height: 100%; background-color: rgba(0,0,0,.8); position:fixed; z-index: 1000; left: 0; top:0;}.w-error-popup-white .w-error-inner{ background-color: #fff; width: 90%; top: 15%; left: 50%; margin-left: -45%; text-align: center; border-radius: 20px; padding: 0; z-index: 1001; position: relative;}.w-error-popup-white .w-error-inner h4{ font-size: 20px; color: #333; padding: 16px 0; margin: 0 32px; border-bottom: 1px solid #e5e9ec; font-weight: normal; }.w-error-popup-white .w-error-inner .w-error-content{ color: #333; font-size: 16px; line-height: 45px; padding: 32px; height: 270px; overflow-y:auto; overflow-x:hidden; text-align: left; }.w-close{ background: url(../images/result-error-x.png) no-repeat right 16px; float: right; right:18px; top:0; position:absolute; z-index: 999; width: 100px; height:85px; cursor:pointer; display: block; background-size:60%;}/*u-btn */.u-btn{ padding: 16px 80px; background-color: #92c153; border-bottom: 5px solid #7da646; border-radius: 8px; color: #fff; display: inline-block; vertical-align: middle;}.u-btn-red{ background-color: #ec7d69; border-color: #e95c44;}</style></head><body><input type="button" value="模拟confirm" id="confirmId" onclick="confirmClickMethed()"/><input type="button" value="模拟alert" id="alertId" onclick="alertClickMethed()"/> <!-- 所有页面都共享confirm提示框 --> <div id="w-error-popup-white" style="display: none;" class="w-error-popup-white"> <div class="w-error-back"></div> <div class="w-error-inner"> <div id="w-confirm-content" class="w-error-content" style="height: auto; font-size: 26px;"> 取消后不能恢复,确定取消么?</div> <div class="btn" style="padding: 1rem; text-align: right;"> <a class="u-btn u-btn-red" href="javascript:canclePopup();">取消</a> <a id="sure" class="u-btn" href="javascript:sure();">确定</a> </div> </div> </div> <!-- 所有页面都共享alert提示框 --> <div id="w-alert-popup-white" style="display: none;" class="w-error-popup-white"> <div class="w-error-back"></div> <div class="w-error-inner"> <div id="w-alert-content" class="w-error-content" style="height: auto; font-size: 26px;"> 这是提示内容 </div> <div class="btn" style="padding: 1rem; text-align: right;"> <a class="u-btn u-btn-red" href="javascript:alertHide();">确定</a> </div> </div> </div> <script type="text/javascript"> function sure(){ $("#w-error-popup-white").hide(); alert("确定"); }function canclePopup(){ $("#w-error-popup-white").hide();}function alertHide(){ $("#w-alert-popup-white").hide();}function confirmClickMethed(){ $("#w-confirm-content").html("这是一个confirm内容,取消还是确认呢?"); $("#w-error-popup-white").show();}function alertClickMethed(){ $("#w-alert-content").html("这是一个alert内容"); $("#w-alert-popup-white").show();}</script></body></html>
文件需要引入jquery。下载地址为:
链接: http://pan.baidu.com/s/1qWxOoC8 密码: w541

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。

本文讨论了HTML&lt; Progress&gt;元素,其目的,样式和与&lt; meter&gt;元素。主要重点是使用&lt; progress&gt;为了完成任务和LT;仪表&gt;对于stati

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

本文讨论了html&lt; datalist&gt;元素,通过提供自动完整建议,改善用户体验并减少错误来增强表格。Character计数:159

本文讨论了HTML&lt; meter&gt;元素,用于在一个范围内显示标量或分数值及其在Web开发中的常见应用。它区分了&lt; meter&gt;从&lt; progress&gt;和前

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

GiteePages静态网站部署失败:404错误排查与解决在使用Gitee...
