CSS代码格式转换工具

 网上找到个小工具,可以转换CSS的格式,这些竖排横排都可以了。
/*会自动去除多余空格

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> CSS 代码格式化工具 </title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <style type="text/css">
 a {color:blue; font-size:12px}
 textarea {width:100%; height:300px; display:block; margin:10px 0; font-size:12px}
 input {font-size:12px}
  </style>
  <script type="text/javascript">
  <!--
 function formatCSS(n){
  var c = document.getElementById("abc");
  var d = document.getElementById("def");
  var v = c.value;
  if (n==1){
   d.value = v.replace(//r/n/g,"").replace(/}/g,"}/r/n").replace(//*///g,"*//r/n");
  }
  if (n==2){
   d.value = v.replace(//r/n/g,"").replace(/}/g,"}/r/n").replace(//s*;/s*/g,";").replace(/;/g,";/r/n/t").replace(/{/g,"{/r/n/t").replace(/}/g,"/r/n}").replace(//*///g,"*//r/n");
  }
  if (n==3){
   c.value = d.value = "";
  }
 }
  //-->
  </script>
 </head>

 <body onload="document.getElementById(abc).focus()">
 <h1>CSS 代码格式化工具</h1>
<textarea id="abc" cols=150 rows=20 wrap="off" title="在这里输入CSS代码"></textarea>

<input type="button" value=" 横排 " onclick="formatCSS(1)" />
<input type="button" value=" 竖排 " onclick="formatCSS(2)" />
<input type="button" value=" 清空 " onclick="formatCSS(3)" />

<textarea id="def" cols=150 rows=20 wrap="off" title="这里将输出CSS代码"></textarea>

<a href="http://www.happyshow.org" target="_blank">happyshow.org</a>
 </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值