How do I make a component centered?

Source: Internet
Author: User
To solve this problem to understand a concept is the box, the box is like the layout of XML, the whole page as a large box <body ></body> What you have to do is put the first level of layout on the first floor, The entire page is then split into each control so that each level two control can be viewed as a box, so that it is placed until the control can no longer be dropped so that it is clear how to center a control.

So now it's time to provide solutions

The center is supported by the parent control. If the parent control is wrap content, it's not to say how the child controls are centered, because the tinkering and layout of the control is done inside the parent control, that is, the parent control must have a certain size, so the control has a certain operating space, the following code is <table>

Table {  
width:700px;
}
TR {
text-align:center;
}

Here only the CSS code, obviously this is consistent with the above, in order to fit the screen, do not recommend the use of Pixel direct operation, but use the next relative value to operate, the following is the modified code

<table width= "100%" border= "1" >
<tr align= "center" >
    <td> Hello </td>
    <td> Hello </td>
</tr>
<tr>
    <td> Hello </td>
</tr>
    <tr> <td> Hello </td>
</tr>
<tr>
    <td> Hello </td>
</tr>

</table>

Show results

Hello Hello
Hello
Hello
Hello

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.