Animate text alignment using jquery

前端 未结 1 1880
天涯浪人
天涯浪人 2020-12-21 19:45

At the click of a button $(\'#btn\').click(), I want a group of span elements be set with CSS text-align right (originally text-aligned left) and m

1条回答
  •  滥情空心
    2020-12-21 20:09

    HTML markup (no change)

    Strings
    Strings

    CSS markup

    .info {
        display: block;   /* width works better on block level elements */
        text-align: right;
        width: 20%;       /* use something sensible as the default value */
        overflow: hidden; /* if you choose 0% for the above property then use this */
    }
    

    jQuery code

    $(document).ready(function() {
        $(".info").animate({
            width: "100%"
        }, 1000);
    });
    

    Demo here

    PS: I'd rather use CSS position relative+absolute along with CSS overflow+left properties.

    0 讨论(0)
提交回复
热议问题