使用自定义 CSS 或更改 HTML 代码将自定义液体按钮水平居中在容器中

问题描述 投票:0回答:2
html css
2个回答
0
投票

表格默认不占据 100% 的宽度。您需要专门定义它:

<table style="width:100%">
  <tbody>
    <tr>
      <td colspan="2" align="center"><input type="image" src="https://my.payfast.io/images/buttons/Subscribe/Dark-Large-Subscribe.png" alt="Subscribe" title="Subscribe with Payfast" /></td>
    </tr>
  </tbody>
</table>

此外,我建议一个简单的

<div style="text-align:center">
insetad。


0
投票

默认情况下,表格元素不会遮挡父元素的全角。只需将表格宽度设置为 100%,按钮就会水平居中对齐。

<table style="width: 100%">
  <tbody>
    <tr>
      <td colspan="2" align="center"><input type="image" src="https://my.payfast.io/images/buttons/Subscribe/Dark-Large-Subscribe.png" alt="Subscribe" title="Subscribe with Payfast" /></td>
    </tr>
  </tbody>
</table>
© www.soinside.com 2019 - 2024. All rights reserved.