Center text in table cell

后端 未结 2 959
面向向阳花
面向向阳花 2021-01-07 16:37

I can\'t seem to find the answer to my issue. I have a table with two rows and two columns (like the code shown below), how do I center align the text in specific cells. I w

2条回答
  •  一生所求
    2021-01-07 16:48

    I would recommend using CSS for this. You should create a CSS rule to enforce the centering, for example:

    .ui-helper-center {
        text-align: center;
    }
    

    And then add the ui-helper-center class to the table cells for which you wish to control the alignment:

    Content
    

    EDIT: Since this answer was accepted, I felt obligated to edit out the parts that caused a flame-war in the comments, and to not promote poor and outdated practices.

    See Gabe's answer for how to include the CSS rule into your page.

提交回复
热议问题