When doing the project, the most disgusting is the field name of different words, such as "name", "Company Name", "mobile phone number", similar to the problem really let the head big.
Now write an JQ method to solve the problem.
First on
Now paste the code:
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <Metaname= "Viewport"content= "Width=device-width, User-scalable=no, target-densitydpi=device-dpi">6 <Metaname= "Author"content= "Haley">7 <Metaname= "Keywords"content="">8 <Metaname= "Description"content="">9 <Scriptsrc= "Http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></Script>Ten <title>Solve the problem of different Chinese word number alignment</title> One </Head> A <Body> - <H2> - December 9, 2016 Haley solve the problem of different Chinese word alignment the </H2> - <Divstyle= "padding-left:30px;width:290px;"> - <Pclass= "Namels">Phone number</P> - <Pclass= "Namels">Name</P> + <Pclass= "Namels">Fixed telephone</P> - <Pclass= "Namels">Chinese company Name</P> + <Pclass= "Namels">ZIP code number</P> A <Pclass= "Namels">A special field name</P> at <Pclass= "Namels">Another special field name</P> - <Pclass= "Namels">Another special field name</P> - </Div> - <Script> - (function($){ - $.fn.extend ({ in 'ls':function(){ - vararr=[]; to $.each ( This,function(){ + Arr.push ($ ( This). HTML (). Split ("'). length); - }); the Console.log (arr); * $.each ( This,function(){ $ varMax=Math.max.apply (NULL, arr);Panax Notoginseng varN=$( This). HTML (). Split ("'). length; - Console.log ("Max:"+max); the varls=(Max-N)/(n-1); + $( This). css ({ A 'letter-spacing': LS+'em' the }); + }); - $ } $ }); - }) (jQuery); - $('. Namels'). LS (); the </Script> - </Body>Wuyi </HTML>
Basic can meet the normal needs. But there is a small bug, the right side of the more than a bit, need to adjust.
Haley solve the problem that the words in the word segment name are not simultaneously justified