将div对齐到页面中心 [英] Aligning div to center of page

查看:165
本文介绍了将div对齐到页面中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div style="text-align:center;">
        <select id="sponsorList"></select>&nbsp;<img alt="Loading..." src="../../Img/ajax-loader.gif" id="loader" />
        <span style="display:none;" id="selectedSponsorId"></span>
        <div id="sponsorRowDetails" style="margin-left:auto; margin-right:auto;">
            <table>
                <tbody>
                    <tr>
                        <td>Effective Date: </td>
                        <td><input type="text" id="startDate" /><br /></td>
                    </tr>
                    <tr>
                        <td>End Date: </td>
                        <td><input type="text" id="endDate" /></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

因此选择 ,但我不能得到 sponsorRowDetails 中心对齐的所有内容。

So the select box is in the center, but I can't get everything within the sponsorRowDetails center aligned as well.

我很可怕CSS这样的东西。我究竟做错了什么?我也尝试了 text-align:center; 与其他div,以及只保持表直接在第一个div。

I'm terrible with simple CSS things like this. What am I doing wrong? I also tried text-align:center; with the other div, as well as just keeping the table directly in the first div.

推荐答案

对于您的sponsorRowDetails中的表执行此操作 div

Do this instead for the table inside your sponsorRowDetails div

< table align =centerstyle =margin:0 auto;>

这篇关于将div对齐到页面中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆