How to right align a

tag?

后端 未结 2 462
一整个雨季
一整个雨季 2021-01-02 10:59

I have a couple of

tags that I want to right align. Does anyone know how to do this?

相关标签:
2条回答
  • 2021-01-02 11:45

    CSS:

    p {
        text-align: right;
    }
    

    INLINE:

    <p style="text-align: right">Some Text</p>
    

    jQuery:

    $('p').css('text-align', 'right');
    

    Javascript:

    var aElements = document.getElementsByTagName('p');
    for (var i = 0; i < aElements.length; i++) {
        aElements[i].style.textAlign = 'right';
    }
    
    0 讨论(0)
  • 2021-01-02 11:51

    It depends. Do you want the entire paragraph to align to the right side of whatever container it's in? Or do you want the text of the paragraph to align to the right margin of the paragraph?

    If it's the first, look into the float: right; CSS directive. The latter, text-align: right;

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