CSS壓縮混淆 / 格式化 / 美化,css混淆

來源:互聯網
上載者:User

CSS壓縮混淆 / 格式化 / 美化,css混淆

<!doctype html>
<html><head>
<meta charset="utf-8">
<title>CSS壓縮混淆 / 格式化 / 美化工具</title>
<style type="text/csss">
@charset "utf-8";
/* CSS Document */

*{margin:0; padding:0; font-family:"Microsoft YaHei UI"; font-size:14px; color:#444;}
img{border:none;}
li {list-style:none;}
a{text-decoration:none}
#wrap{ width:960px; margin:0 auto;}
#head, #mainbody, #foot{ width:100%;}

/*表單控制項樣式 start*/
.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;}
.tarea-on{color:#000;}
textarea{ overflow:auto; vertical-align:top;}
.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;}
/*表單控制項樣式 end*/

.subbtn { margin-left:50px; margin-bottom:10px;}
.center h2{ margin-left:30px;}
.sitetip{ margin-bottom:12px;}

</style>
</head>
<body>
<div id="wrap">
<div id="head"></div>
<div id="mainbody">
<div class="center">
<h1>CSS壓縮混淆 / 格式化 / 美化工具</h1>
<hr />
<h2 class="sitetip">貼入要格式化或壓縮的CSS代碼:</h2>
<textarea id="code" class="tarea">格式化或壓縮的CSS代碼</textarea>
<div class="subbtn">
<input type="button" onClick="CSS('packAdv')" value="進階壓縮" class="sbtn" />
<input type="button" onClick="CSS('pack')" value="普通壓縮" class="sbtn" />
<input type="button" onClick="CSS('format')" value="格式化" class="sbtn" />
</div>
<h2 class="sitetip">轉換後的css代碼: </h2>
<textarea id="packer" class="tarea tarea-on"></textarea>
</div>
</div>
<div id="foot"></div>
</div>
<script type="text/javascript">
/**
* css 壓縮 格式化
*/
var CSSCoder = {
format: function (s) {//格式化
s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");
s = s.replace(/;\s*;/g, ";");
s = s.replace(/\,[\s\.\#\d]*{/g, "{");
s = s.replace(/([^\s])\{([^\s])/g, "$1 {\n\t$2");
s = s.replace(/([^\s])\}([^\n]*)/g, "$1\n}\n$2");
s = s.replace(/([^\s]);([^\s\}])/g, "$1;\n\t$2");
return s;
},
packAdv: function (s) {//進階壓縮
s = s.replace(/\/\*(.|\n)*?\*\//g, "");
s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");
s = s.replace(/\,[\s\.\#\d]*\{/g, "{");
s = s.replace(/;\s*;/g, ";");
s = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
return (s == null) ? "" : s[1];
},
pack: function (s) {//普通壓縮
s = s.replace(/\/\*(.|\n)*?\*\//g, "");
s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");
s = s.replace(/\,[\s\.\#\d]*\{/g, "{");
s = s.replace(/;\s*;/g, ";");
s = s.replace(/;\s*}/g, "}");
s = s.replace(/([^\s])\{([^\s])/g, "$1{$2");
s = s.replace(/([^\s])\}([^\n]s*)/g, "$1}\n$2");
return s;
}
};

function CSS(s) {
document.getElementById("packer").value = CSSCoder[s](document.getElementById("code").value);
}
</script>
</body>
</html>

介面顯示如所示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.