HTML将宽度为110%的表格行居中

时间:2019-02-26 10:14:17

标签: php html

我在HTML电子邮件中有一个表格行,除非将宽度设为110%,否则无法容纳所有内容。

唯一的问题是表格现在向右延伸。整个表格的宽度设置为600px。

我发现将宽度增加到110%是使文字无法在手机上包裹的唯一方法。

有人可以告诉我即使宽度增加了如何使这一行居中吗?

代码是-

<div style="margin-bottom: 30px; margin-top: 30px;">

<table class="td" cellspacing="0" cellpadding="6" style="width: 110%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border-left: none; border-right: none; border-top: 1px solid #000; border-bottom: 1px solid #000;" border="0"; align="center">
<tbody>                                         
<?php $items = $order->get_items();
foreach ($items as $item) {
$product = new WC_Product($item['product_id']);?>                                           <tr>   
<td><?php echo $product->get_image($size = 'shop_thumbnail'); ?></td>
<td><?php echo $product->get_title(); ?> </td>
<td><a href="<?php echo $url = get_permalink($product->id).'#reviews'; ?>" style="background-color: #000; color: #fff; text-decoration: none; padding: 10px;">REVIEW NOW</a></td>
</tr>
<?php                                           
}                                           
?>                                          
</tbody>                                        
</table>                                        
</div>

谢谢!!

附件中有一张图片,您可以在其中看到“立即评论”部分,其内容超出了上述部分。我只想将此居中。

enter image description here

2 个答案:

答案 0 :(得分:1)

尝试使用“ nowrap”关键字

<td nowrap><?php echo $product->get_image($size = 'shop_thumbnail'); ?></td>

答案 1 :(得分:0)

您必须检查表属性: Tablepropertie