Haley solve the problem that the words in the word segment name are not simultaneously justified

Source: Internet
Author: User

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

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.