首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使按钮在表格中居中

使按钮在表格中居中
EN

Stack Overflow用户
提问于 2020-02-07 19:24:11
回答 2查看 43关注 0票数 0

我在一张桌子里做了一个按钮,但没能把它放在中心。你能帮上忙吗?我认为CSS是不正确的,但无法使其运行。任何帮助都将不胜感激。此外,按钮应该显示在电子邮件中,以防这会造成不同。

代码语言:javascript
复制
.button a {
    padding: 8px 12px;
    border-radius: 4px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 16px;
    color: #ffffff; 
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    float: none;
    
    
}
代码语言:javascript
复制
<tr>
                                      <td class="plr-10" style="padding:0 60px;">
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tbody style=""><tr>
                                            <td style="padding-bottom: 10px;">
                                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tbody><tr style="">
                                                  <td class="text-16 tx-grey" valign="top" width="10" style="font-family:'Segoe UI', Arial, sans-serif;font-size:16px;line-height:26px;text-align:left;min-width:auto !important;color:#929292;">
                                                    <strong style="font-weight: bold;">
                                                      <br>1.</strong>
                                                    </td>
                                                    <td class="img" width="10" style="font-size:0pt;line-height:0pt;text-align:left;"></td>
                                                    <td class="text-16" valign="top" style="color: rgb(37, 46, 93); font-family: &quot;Segoe UI&quot;, Arial, sans-serif; font-size: 16px; line-height: 26px; text-align: left; min-width: auto !important;"><br>
Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample text .</td>
                                                    </tr>
                                                  </tbody></table>
                                                </td>
                                              </tr>
                                              
                                              
                                              
                                              
                  
                  <tbody><tr>
                  <td class="button a">
                      <table width="40%" border="0" cellspacing="0" cellpadding="0">
                        <tbody><tr>
                          <td class="button" style="padding-bottom:25px; text-align: center">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tbody><tr>
                              	<td class="button" width="240" style="font-family:'Segoe UI', Arial, sans-serif;font-size:12px;line-height:16px;min-width:auto !important;text-align:center;color:#ffffff;" bgcolor="#1b55f5" >
                                  <a href="" target="_blank" class="link-grey" style="color:#b5b5b5;text-decoration:none;"><span class="link-grey" style="color: #ffffff; text-decoration: none;">Browse</span></a>
                                </td>
                              </tr>
                            </tbody></table>
                          </td>
                        </tr>
                      </tbody></table>
                    </td>
                  </tr>

EN

回答 2

Stack Overflow用户

发布于 2020-02-10 19:57:24

尝试使用实际的按钮:

代码语言:javascript
复制
<table style="width: 100%;">
    <tbody>
        <tr>
            <td style="text-align: center;">
                <button class="button">hello</button>
            </td>
        </tr>
    </tbody>
</table>
票数 0
EN

Stack Overflow用户

发布于 2020-02-10 20:45:57

这将使按钮本身居中:

代码语言:javascript
复制
.button {
    display: flex;
    justify-content: center;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60112497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档