CSS Code formatting tools

Source: Internet
Author: User

CSS Code formatting tools


    1. CSS code formatting tools can: Compress code, format (multiple lines), format (single line), restore code.

    2. Easy to optimize and save space


The following is the source code:

-------------------------------------

<! DOCTYPE HTML >

<meta charset= "UTF-8" >


<title>css Formatting Tools </title>

<style type= "Text/css" >


Html,body,form,fieldset,textarea {height:100%; margin:0; padding:0; border:0; font-size:10pt; background: #eee;}

form {margin:0 1%; Overflow:hidden; }

Legend {line-height:3em; font-weight:bolder;}

button {float:left; margin:1% 1% 0 0; cursor:pointer;}

textarea {width:100%; height:20em; border:1px solid #ccc; display:block; background: #fff;}

</style>

<form action= "" onsubmit= "return false" >

<fieldset>

<legend>css Formatting Tools </legend>

<textarea name= "" rows= "" cols= "" id= "Codetext" >body * {font-size:10pt;} /* SS SDA */

P

{clear:left; padding:5px 10px;

}

Td

,

FieldSet

{padding: 10px; }

TEXTAREA {

width:90%;

Height:10em;

}

</textarea>

<button type= "button" onclick= "$ (& #39;codetext& #39;). Value=code. A (); " > Compression Codes </button>

<button type= "button" onclick= "$ (& #39;codetext& #39;). Value=code. B (); " > Format (multiple lines) </button>

<button type= "button" onclick= "$ (& #39;codetext& #39;). Value=code. C (); " > Format (single line) </button>

<button type= "button" onclick= "$ (& #39;codetext& #39;). Value=code. Z (); " > Restore Code </button>

</fieldset>

</form>

<script type= "Text/javascript" >

function $ (ID) {return document.getElementById (ID);}

function Codezip (obj) {

This. S=function () {

var Code=obj.value;

if (!this.codez| | this.codez== "") This.codez=code;

Code=code.replace (/(\n|\t|\s) */ig, ' $ ');

Code=code.replace (/\n|\t|\s (\{|\}|\,|\:|\;)/ig, ' $ $ ');

Code=code.replace (/(\{|\}|\,|\:|\;) \s/ig, ' $ $ ');

return code;

}

This. A=function () {

var code=this. S ();

return code;

}

This. B=function () {

var code=this. S ();

Code=code.replace (/(\{)/ig, ' $ ');

Code=code.replace (/(\{|\;)/ig, ' $1\n\t ');

Code=code.replace (/\t* (\})/ig, ' $1\n ');

Code=code.replace (/(\*\/)/ig, ' $1\n ');

return code;

}

This. C=function () {

var code=this. S ();

Code=code.replace (/(\})/ig, ' $1\n ');

Code=code.replace (/(\*\/)/ig, ' $1\n ');

return code;

}

This. Z=function () {

Return (This.codez)? This.codeZ:obj.value;

}

var my=this;

Obj.onkeydown=function () {

My.codez= "";

}

}

var code=new codezip ($ (' codetext '));

</script>

</body>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/98/wKioL1YCEyWz05LPAAJJ_Rdv2Bc473.jpg "title=" Dzq-blog.png "alt=" Wkiol1yceywz05lpaajj_rdv2bc473.jpg "/>




This article from "Wennuanyiran" blog, reproduced please contact the author!

CSS Code formatting tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.