在一些表单等需要弹窗提醒的时候,每个浏览器都有一个alert(),comfirm()函数能弹出信息,但是浏览器的自带的这种效果样式不统一,而且都固定在页面顶部;
smoke.js轻量级的JS插件,他标准化浏览器的alert(), comfirm()效果。完全是由html、css、js编写;
- 要求:CSS3支持
- 兼容性:大部分浏览器,包括IE6(没有CSS3可视化效果)
- License:MIT
使用方法:本文使用的是click事件,你也可以自定义事件触发类型;
<body> <a href="#" rel="demo-alert">alert</a> <a href="#" rel="demo-confirm">confirm</a> <a href="#" rel="demo-prompt">prompt</a> <a href="#" rel="demo-quiz">quiz</a> <a href="#" rel="demo-signal">signal</a></body>
样式:
.smoke-base { position: fixed; top: 0; left: 0; bottom: 0; right: 0; visibility: hidden; opacity: 0; } .smoke-base.smoke-visible { opacity: 1; visibility: visible; } .smokebg { position: fixed; top: 0; left: 0; bottom: 0; right: 0; } .smoke-base .dialog { position: absolute; } .dialog-prompt { margin-top: 15px; text-align: center; } .dialog-buttons { margin: 20px 0 5px 0 } .smoke { font-family: Menlo, 'Andale Mono', monospace; text-align: center; font-size: 22px; line-height: 150%; } .dialog-buttons button { display: inline-block; vertical-align: baseline; cursor: pointer; font-family: Menlo, 'Andale Mono', monospace; font-style: normal; text-decoration: none; border: 0; outline: 0; margin: 0 5px; -webkit-background-clip: padding-box; font-size: 13px; line-height: 13px; font-weight: normal; padding: 9px 12px; } .dialog-prompt input { margin: 0; border: 0; font-family: sans-serif; outline: none; font-family: Menlo, 'Andale Mono', monospace; border: 1px solid #aaa; width: 75%; display: inline-block; background-color: transparent; font-size: 16px; padding: 8px; } .smoke-base { background: rgba(0,0,0,.3); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#90000000,endColorstr=#900000000); } .smoke-base .dialog { top: 25%; width: 30%; left: 50%; margin-left: -20%; } .smoke-base .dialog-inner { padding: 15px; color:#202020; } .smoke { background-color: rgba(255,255,255,0.95); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff,endColorstr=#ffffff); box-shadow: 0 2px 8px #000; } .dialog-buttons button { background-color: rgba(0,0,0,.85); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#222222,endColorstr=#222222); border-radius: 0; color: #fff; } button.cancel { background-color: rgba(0,0,0,.40); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#444444,endColorstr=#444444); } .queue{ display:none; }
alert()效果--smoke.alert(string, fn,obj)
string--弹出框文字内容,fn--回调函数,obj--{ok:'按钮文字',cancel:'取消按钮文字',classname:'叠加的弹窗框样式名'}
/*alert*/ $('a[rel="demo-alert"]').on('click',function(e){ e.preventDefault(); smoke.alert("Wouldn't it be funny if Animal Collective was an actual<br /> collective of actual animals?", function(e){ smoke.signal('No really...it totally would, dude.<br />I mean, think about it.'); },{ ok: "Yep", //确定按钮文字 cancel: "Nope", //取消按钮文字 classname: "custom-class" //弹出框样式 }); });
confirm效果--smoke.confirm(string,fn,obj)
/*confirm*/ $('a[rel="demo-confirm"]').on('click',function(e){ e.preventDefault(); smoke.confirm("Slippery breath inside<br /> banjo melted. Runny smoky. ",function(e){ if (e){ //确定按钮回调 smoke.signal('Perfect. We\'ll be in touch.'); //点击按钮响应lightbox效果,基本上看不见,因为没有设置延迟时间 smoke.signal()会闪一下就消失了。 }else{ //取消按钮回调 smoke.signal('Please...me so sorry. You look good in dress, you look better on my floor.'); } }, { reverseButtons: true, //确定和取消按钮哪个在前;true ok按钮在前,false cancel按钮在前 classname: "custom-class", ok: "AGREE", //确定文字 cancel: "DISAGREE" //取消文字 }); });
quiz效果--smoke.quiz(string, fn, obj),多按钮(最多三个)
/*quiz*/ $('a[rel="demo-quiz"]').on('click',function(e){ e.preventDefault(); smoke.quiz('Which of these things<br /> is the worst thing?', function (e){ if (e == 'DISCO'){ //点击每个按钮的触发的效果 smoke.signal('nope. it\'s funk.'); } if (e == 'REGGAE'){ smoke.signal('nope. it\'s disco.'); } if (e == 'FUNK'){ smoke.signal('nope. it\'s reggae.'); } }, { button_1 : "DISCO", //多按钮(最多三个) button_2 : "REGGAE", button_3 : "FUNK", button_cancel: "NONE OF THEM" //取消按钮 } ); });
signal,设置弹出框,没有按钮,可以设置弹框消失的延迟时间
/*signal*/ $('a[rel="demo-signal"]').on('click',function(e){ e.preventDefault(); smoke.signal('Congratulations! You have just one a free iPod Touch!', function(){}, {duration: 5000, classname: "custom-class"}); //duration:5000设置延迟时间为5000毫秒 });
prompt,带有输出框的alert效果
/*prompt*/ $('a[rel="demo-prompt"]').on('click',function(e){ e.preventDefault(); o.prompt_demo(1); });var o={ prompt_demo: function(ver){ var q = 'What\'s in the bag?'; //设置提示文字,这个是用来遵循文本框的内容约束规则。文本框如果是必填的话就会需要,在用户移除文本框的时候就会触发提示文字。 if (ver == 2){ q = 'No no, you HAVE to answer.<br /> What\'s in the bag?'; } smoke.prompt(q, function(e){ if (e){ //ok按钮的效果 smoke.signal('You have no idea how badly<br /> I need a bag of '+e+'. <br /><br /> Give it to me. Right now.<br /><br />'); }else{ //cancel按钮效果 o.prompt_demo(2); } }, { reverseButtons: true, //翻转按钮顺序 value: 'hammers', //文本框里的默认内容 ok: 'Have a look', //确定按钮文字 cancel: 'None of your business' //取消按钮文字 }); }}
鼠标移除文本框后或单击cancel按钮

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version
