CSS压缩混淆 / 格式化 / 美化工具 <br />@charset "utf-8";<br />/* CSS Document */ <p>*{margin:0; padding:0; font-family:"Microsoft YaHei UI"; font-size:14px; color:#444;}<br />img{border:none;}<br />li {list-style:none;}<br />a{text-decoration:none}<br />#wrap{ width:960px; margin:0 auto;}<br />#head, #mainbody, #foot{ width:100%;} <p>/*表单控件样式 start*/<br />.tarea { margin-left:20px; width:90%; height:220px; border:1px solid #e6e6e6; margin-bottom:12px; box-shadow:inset 1px 1px 1px #eee; padding:4px; border-radius:2px; line-height:18px; color:#CCC; font-size:12px;}<br />.tarea-on{color:#000;}<br />textarea{ overflow:auto; vertical-align:top;}<br />.sbtn{ cursor:pointer; display: inline-block; vertical-align:middle;height:27px; line-height:27px; padding:0 12px; border-radius:2px; border:1px solid #ddd; text-align:center;}<br />/*表单控件样式 end*/ <p>.subbtn { margin-left:50px; margin-bottom:10px;}<br />.center h2{ margin-left:30px;}<br />.sitetip{ margin-bottom:12px;} <p> CSS压缩混淆 / 格式化 / 美化工具 贴入要格式化或压缩的CSS代码: 格式化或压缩的CSS代码 转换后的css代码: <br />/**<br />* css 压缩 格式化<br />*/<br />var CSSCoder = {<br /> format: function (s) {//格式化<br /> s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");<br /> s = s.replace(/;\s*;/g, ";");<br /> s = s.replace(/\,[\s\.\#\d]*{/g, "{");<br /> s = s.replace(/([^\s])\{([^\s])/g, "$1 {\n\t$2");<br /> s = s.replace(/([^\s])\}([^\n]*)/g, "$1\n}\n$2");<br /> s = s.replace(/([^\s]);([^\s\}])/g, "$1;\n\t$2");<br /> return s;<br /> },<br /> packAdv: function (s) {//高级压缩<br /> s = s.replace(/\/\*(.|\n)*?\*\//g, "");<br /> s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");<br /> s = s.replace(/\,[\s\.\#\d]*\{/g, "{");<br /> s = s.replace(/;\s*;/g, ";");<br /> s = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);<br /> return (s == null) ? "" : s[1];<br /> },<br /> pack: function (s) {//普通压缩<br /> s = s.replace(/\/\*(.|\n)*?\*\//g, "");<br /> s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");<br /> s = s.replace(/\,[\s\.\#\d]*\{/g, "{");<br /> s = s.replace(/;\s*;/g, ";");<br /> s = s.replace(/;\s*}/g, "}");<br /> s = s.replace(/([^\s])\{([^\s])/g, "$1{$2");<br /> s = s.replace(/([^\s])\}([^\n]s*)/g, "$1}\n$2");<br /> return s;<br /> }<br />}; <p>function CSS(s) {<br /> document.getElementById("packer").value = CSSCoder[s](document.getElementById("code").value);<br />}<br /> 界面显示如下图所示