js实现浏览器中移除包含style的html代码中的无用css代码
代码语言:html
所属分类:其他
代码描述:js实现浏览器中移除包含style的html代码中的无用css代码,移除完整html中包含style的css代码没有用到过的css,移除返回dom中会使用的css代码。
代码标签: js 浏览器 移除 包含 style html 代码 无用 css 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>未使用 CSS 移除工具</title> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwindcss.3.4.16.js"></script> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.5.1.css"> <style> body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f8fafc; } .toast { position: fixed; bottom: 1.25rem; right: 1.25rem; padding: 1rem; border-radius: 0.5rem; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); color: white; z-index: 50; display: flex; align-items: center; gap: 0.75rem; transition: all 0.3s ease; transform: translateY(200%); } .toast.show { transform: translateY(0); } </style> </head> <body class="p-4 sm:p-8 text-slate-800"> <div class="max-w-4xl mx-auto"> <header class="text-center mb-8"> <h1 class="text-3xl sm:text-4xl font-extrabold text-slate-900"> <i class="fas fa-cut text-indigo-600"></i> 未使用 CSS 移除工具 </h1> <p class="mt-2 text-slate-600">粘贴包含style 标签的 HTML 代码,工具将分析并仅返回被使用到的 CSS。</p> </header> <div class="space-y-6"> <div> <label for="html-input" class="block text-sm font-medium text-slate-700 mb-1">输入 HTML 代码:</label> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0