Giter Club home page Giter Club logo

text-align's Introduction

jQuery Text Alignment Plugin

Imagine you have worked hard to make your tables look good, but one thing keeps bugging you; the alignment of the text in the cells. You would, for example, like to align the contents of each cell on the comma character. Unfortunately, no browser supports aligning table cells on characters. This is where the jQuery Text Alignment Plugin comes in; it adds support for aligning text based on characters to all browsers.

Please keep in mind that when this plugin is used to align on characters, it will convert the children of the element it is called on to text, and apply the alignment to that. Inline markup will thus be effectively removed. Future versions of this plugin might correct this, once I figure out what to do with complex content.

The following examples selects all the cells in an example table, then uses the jQuery Column Selector plugin to select the first column, and finally aligns the cells in that column on the comma character.

$('#example td:nth-col(1)').textAlign(',');

The textAlign method only accepts a single parameter, and will align all selected elements according to the same criteria. The method returns the elements it was called on, and can thus be chained.

textAlign(str)
Aligns the text in the selected elements according tostrparameter. The parameter can either be one of the following keywords, or a single character:
left
Align the elements to the left.
        <dt>right</dt>
        <dd>Align the elements to the right.</dd>
        
        <dt>center</dt>
        <dd>Align the elements centered.</dd>
        
        <dt>justify</dt>
        <dd>Align the elements justified.</dd>
        
        <dt>start</dt>
        <dd>Align the elements according to the left-to-right locale (start means left in western languages.)</dd>
        
        <dt>end</dt>
        <dd>Align the elements according to the left-to-right locale (end means right in western languages.)</dd>
        
        <dt>&lt;character&gt;</dt>
        <dd>Align the the elements on the character. Note that elements that do not have the character are aligned as if they ended with the character. The element as a whole is aligned according to the inherited text alignment property.</dd>
    </dl></dd>

Example

Please see the text alignment example page for example code on how to use the plugin.

text-align's People

Contributors

bramstein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.