js+css模拟windows95错误提示无穷无尽效果代码
代码语言:html
所属分类:其他
代码描述:js+css模拟windows95错误提示无穷无尽效果代码
代码标签: js css 模拟 windows 95 错误 提示 无穷无尽
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body, button { color: #000000; cursor: url(//repo.bfw.wiki/bfwrepo/icon/637e1f868f13e.png) 0 0, default; font: 12px/18px "MS Sans Serif", Helvetica, sans-serif; } body { background-color: #188080; display: grid; height: 100vh; overflow: hidden; } .window { background-color: #c0c0c0; box-shadow: -1px -1px 0 #000000 inset, 1px 1px 0 #dfdfdf inset, -2px -2px 0 #808080 inset, 2px 2px 0 #ffffff inset; display: flex; flex-direction: column; position: fixed; top: calc(50% - 60px); left: calc(50% - 148px); padding: 3px; min-width: 296px; min-height: 119px; white-space: nowrap; user-select: none; -moz-user-select: none; -webkit-user-select: none; } .window[hidden] { display: none; } .window__sprite { display: block; position: absolute; top: -1px; left: -1px; width: 1px; height: 1px; } .window__sprite--close { box-shadow: 5px 4px #000000, 6px 4px #000000, 6px 5px #000000, 7px 5px #000000, 7px 6px #000000, 8px 6px #000000, 9px 6px #000000, 10px 6px #000000, 10px 5px #000000, 11px 5px #000000, 11px 4px #000000, 12px 4px #000000, 8px 7px #000000, 9px 7px #000000, 7px 8px #000000, 8px 8px #000000, 9px 8px #000000, 10px 8px #000000, 6px 9px #000000, 7px 9px #000000, 11px 9px #000000, 10px 9px #000000, 5px 10px #000000, 6px 10px #000000, 12px 10px #000000, 11px 10px #000000; } .window__sprite--close-disabled { box-shadow: 5px 4px #808080, 6px 4px #808080, 6px 5px #808080, 7px 5px #808080, 7px 6px #808080, 8px 6px #808080, 9px 6px #808080, 10px 6px #808080, 10px 5px #808080, 11px 5px #808080, 11px 4px #808080, 12px 4px #808080, 8px 7px #808080, 9px 7px #808080, 7px 8px #808080, 8px 8px #808080, 9px 8px #808080, 10px 8px #808080, 6px 9px #808080, 7px 9px #808080, 11px 9px #808080, 10px 9px #808080, 5px 10px #808080, 6px 10px #808080, 12px 10px #808080, 11px 10px #808080, 12px 5px #ffffff, 13px 5px #ffffff, 11px 6px #ffffff, 12px 6px #ffffff, 10px 7px #ffffff, 11px 7px #ffffff, 8px 9px #ffffff, 9px 9px #ffffff, 7px 10px #ffffff, 8px 10px #ffffff, 6px 11px #ffffff, 7px 11px #ffffff, 12px 11px #ffffff, 13px 11px #ffffff; } .window__button { background-color: #c0c0c0; border-radius: 0; box-shadow: 1px 1px 0 #ffffff inset, -1px -1px 0 #808080 inset, 2px 2px 0 #dfdfdf inset, 1px 0 0 #000000, 0 1px 0 #000000, 1px 1px 0 #000000; letter-spacing: 1px; outline: 0; position: relative; min-width: 15px; height: 13px; -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; } .window__button:not(:disabled):active { box-shadow: 1px 1px 0 #000000 inset, -1px -1px 0 #c0c0c0 inset, 2px 2px 0 #808080 inset, 1px 0 0 #ffffff, 0 1px 0 #ffffff, 1px 1px 0 #ffffff; padding: 1px 0 0 1px; } .window__button--lg { box-shadow: -1px -1px 0 #000000 inset, 1px 1px 0 #ffffff inset, -2px -2px 0 #808080 inset; padding: 1px 0 0 1px; min-width: 75px; height: 23px; } .window__button--lg:not(:disabled):active { box-shadow: 0 0 0 1px #000000 inset, 0 0 0 2px #808080 inset; padding: 3px 0 0 3px; } .window__button:not(:disabled):active .window__sprite { transform: translate(1px, 1px); } .window__header, .window__body, .window__footer { display: flex; } .window__header { background-color: #808080; color: #c0c0c0; justify-content: space-between; padding: 2px 3px; width: 100%; height: 18px; } .window--active .window__header { background-color: #120180; color: #ffffff; } .window--active .window__button--lg { box-shadow: 0 0 0 1px #000000 inset, -2px -2px 0 #000000 inset, 2px 2px 0 #ffffff inset, -3px -3px 0 #808080 inset, 3px 3px 0 #dfdfdf inset; } .window--active .window__button--lg:before { background: linear-gradient(90deg, transparent 50%, #000000 50%) 0 0/2px 1px repeat-x, linear-gradient(90deg, transparent 50%, #000000 50%) 0 100%/2px 1px repeat-x, linear-gradient(transparent 50%, #000000 50%) 0 0/1px 2px repeat-y, linear-gradient(transparent 50%, #000000 50%) 100% 0/1px 2px repeat-y; content: ""; display: block; position: absolute; inset: 4px; } .window__header .window__button { margin-left: 10px; } .window__body { flex: 1; padding: 12px 11px 11px 11px; } .window__body-icon { display: block; flex-shrink: 0; margin-right: 16px; width: 32px; height: 32px; } .window__body-text { padding: 8px 0; } .window__footer { justify-content: center; padding: 0 11px 12px 11px; } .window__title { font-weight: bold; line-height: 1; transform: translate(0, -1px); } .window__sr { overflow: hidden; position: absolute; width: 1px; height: 1px; } </style> </head> <body> <div id="error-0" class="window window--active" role="alertdialog" aria-modal="true" aria-labelledby="error-label-0" aria-describedby="error-desc-0" data-window hidden> <div class="window__header" data-header> <div id="error-label-0" class="window__title" data-label>Error</div> <button class="window__button" type="button" disabled> <span class="window__sprite window__sprite--close-disabled"></span> <span class="window__sr">Close</span> </button> </div> <div class="window__body"> <img class="window__body-icon" alt="White X on a red circle with dark red outline and drop shadow" src="//repo.bfw.wiki/bfwrepo/icon/637e1fb2ec4d6.png" width="32" height="32"> <p id="error-desc-0" class="window__body-text" data-desc></p> </div> <div class="window__footer"> <button class="window__button window__button--lg" type="button" data-ok>OK</button> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/howler.2.2.3.js"></script> <script > window.addEventListener("DOMContentLoaded",() => { const system = new Windows95("body"); }); class Windows95 { cursorDragPos = null; errorDragging = null; errorLimit = 50; errors = []; sound = { chord: new Howl({ src: ["//repo.bfw.wiki/bfwrepo/sound/637e1f1b7da6c.wav"], autoplay: false, loop: false, volume: 1.0 }) }; constructor(el) { this.el = document.querySelector(el); this.el?.addEventListener("click", this.errorLoop.bind(this)); this.el?.addEventListener("keyup", this.errorLoop.bind(this)); // down this.el?.addEventListener("mousedown", this.dragErrorStart.bind(this)); this.el?.addEventListener("touchstart", this.dragErrorStart.bind(this)); // move this.el?.addEventListener("mousemove", this.dragError.bind(this)); this.el?.addEventListener("touchmove", this.dragError.bind(this)); // up this.el?.addEventListener("mouseup", this.dragErrorEnd.bind(this)); this.el?.addEventListener("mouseleave", this.dragErrorEnd.bind(this)); this.el?.addEventListener("contextmenu", this.dragErrorEnd.bind(this)); this.el?.addEventListener("touchend", this.dragErrorEnd.bind(this)); this.spawnError(0,0,true); } async errorLoop(e) { const { code, target } = e; if (code === "Enter" || code === "NumpadEnter" || (!code && target?.hasAttribute("data-ok"))) { const activeError = th.........完整代码请登录后点击上方下载按钮下载查看
网友评论0