【问题标题】:Unable to centre align main page无法居中对齐主页
【发布时间】:2017-11-14 09:53:54
【问题描述】:

我有一个 WordPress 主页,所有内容都向左对齐。我想把它们移到中心 > http://www.architravel.com/destinations/.

您能否解释一下我必须做些什么才能使其居中?

那是主页的代码:

<?php
/**
 * Template Name: Home page
 *
 *
 */

get_header(); ?>

<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
    <td height="200" colspan="2" valign="bottom">
    </td>
</tr>
<tr>
    <td colspan="2" valign="bottom">
        <a href="<?php get_home_url(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/destinations_top.jpg" alt="Architravel Destinations" width="518" height="56" border="0"> <div style="clear:both;"></div></a>
    </td>
</tr>
<tr>
    <td colspan="2" bgcolor="#506DAF">
        <img src="<?php echo get_template_directory_uri(); ?>/images/top.jpg" width="1230" height="257" alt="top" >
    </td>
</tr>
<tr>
    <td valign="top" colspan="2">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="405" height="102" valign="top" >
                <a href="http://www.architeam.org/#/projects" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/architeam.jpg" alt="Architeam Projects" width="410" height="102" border="0"></a>
            </td>
            <td valign="top">
                <img src="<?php echo get_template_directory_uri(); ?>/images/planebottom.jpg" align="left" alt="top_bottom">
            </td>
        </tr>
        </table>
        <a href="http://www.architeam.org/#/projects" target="_blank"></a>
    </td>
</tr>
<tr>
    <td colspan="2">
        <table border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td height="50" colspan="10" valign="top">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td width="190" valign="top">
                &nbsp;
            </td>
            <td width="25" valign="top">
                <img src="<?php echo get_template_directory_uri(); ?>/images/doty.jpg" width="20" height="18" alt="doty">
            </td>
            <td valign="middle" style="vertical-align: middle;">
                 Last Destination: &nbsp;
            </td>
            <td width="350" valign="middle" style="vertical-align: middle;">
                <a href="/destinations/trips/los-angeles-las-vegas-san-francisco/" class="front">LOS ANGELES - LAS VEGAS - SAN FRANCISCO</a><br/>
            </td>
            <td width="25" valign="top">
                <img src="<?php echo get_template_directory_uri(); ?>/images/doty.jpg" width="20" height="18" alt="doty">
            </td>
            <td valign="middle" style="vertical-align: middle;">
                Destinations Archive: &nbsp;
            </td>
            <td valign="middle" style="vertical-align: middle;">
                                <a href="/destinations/trips/mexico/" class="front">MEXICO</a> |
                <a href="/destinations/trips/singapore-malaysia/" class="front">SINGAPORE - MALAYSIA</a> | 
                <a href="/destinations/trips/china" class="front">CHINA</a> | 
                <a href="/destinations/trips/brazil" class="front">BRAZIL </a> | 
                <a href="/destinations/trips/zaragoza-bilbao" class="front">ZARAGOZA - BILBAO</a> | 
                <a href="/destinations/trips/japan" class="front">JAPAN</a>
            </td>
        </tr>
        <tr>
            <td height="50" colspan="10" valign="top">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td valign="top">
                &nbsp;
            </td>
            <td colspan="3" valign="top">
                <a href="http://www.architravel.com/archipaper/" target="_blank" title="ArchiPaper"><img src="<?php echo get_template_directory_uri(); ?>/images/archipaper.jpg" alt="ArchiPaper" width="250" height="61" border="0"></a>
            </td>
            <td colspan="3" valign="center">
                <a href="http://www.architravel.com" target="_blank" title="ArchiTravel"><img src="http://www.architravel.com/destinations/wp-content/uploads/2016/06/ArchiTravel_LOGO.png" alt="ArchiTravel" width="250" height="68" border="10"></a>
                &nbsp;
            </td>
            <td valign="top">
                &nbsp;
            </td>
            <td valign="top">
                &nbsp;
            </td>
            <td valign="top">
                &nbsp;
            </td>
            <td valign="top">
                &nbsp;
            </td>
            <td valign="top">
                &nbsp;
            </td>
        </tr>
        </table>
    </td>
</tr>
</table>
<?php get_footer(); ?>

【问题讨论】:

    标签: html css wordpress alignment


    【解决方案1】:

    为了确保它不会被覆盖,我会在 div 中为其分配一个 ID 并对齐 div。

    <div id='table1'>
        <table>
        </table>
    </div>
    

    然后你可以用它来设置样式

    #table1{
        text-align:none;
    }
    

    【讨论】:

      【解决方案2】:

      变化:

      align="left"

      到:

      align="center"

      在你的桌子上。

      【讨论】:

        猜你喜欢
        • 2017-06-03
        • 2018-05-16
        • 2016-07-03
        • 1970-01-01
        • 1970-01-01
        • 2012-05-08
        • 2015-09-15
        • 1970-01-01
        • 2018-12-02
        相关资源
        最近更新 更多