gpt4 book ai didi

php - 100% 宽度的表格行位于表格的中间

转载 作者:行者123 更新时间:2023-12-04 16:15:52 25 4
gpt4 key购买 nike

我网站上的索引页面显示了我的用户最近提交的内容。它使用 HTML 表作为标记,并使用 PHP 生成。 tr 标记如下所示:

<tr>
<td class="preview"><img alt="Minecraft skin preview" src="link"></td>
<td class="skin">
<span class="title"><a href="link">Skin Edit preview broken but I did my best</a></span><br />
<span class="desc">Seraphinite Hunter</span>
</td>
<td class="auth">MikeSilver</td>
<td class="time">23-5-2011</td>
<td class="links">
<a target="_blank" href="link">Download</a><br>
<a target="_blank" href="link">Remote</a>
</td>
</tr>

我想要的是让 AdSense 广告显示在 table 下方大约一半的位置。为此,我将 tr 元素的数量减半并将数字四舍五入,然后在我的 PHP 代码中使用计数器来检测在我的 AdSense 代码中放置的位置。事情是,当我这样做时, table 坏了。

我正在做这样的事情:
<?php $limit = floor($site['skinsPerPage'] / 2); $counter = 0; ?>
<?php foreach($skins as $skin): ?>
<?php if($counter == $limit): ?>
<tr>
<td>
<!-- adsense code -->
</td>
</tr>
<?php else: ?>
<!-- normal table code (as above) -->
<?php endif; ?>
<?php $counter++; ?>
<?php endforeach; ?>

有谁知道我可以用来在表格中间居中的表格单元格中显示此 AdSense 广告的正确样式吗?无论我做什么,它似乎都打破了 table ,并插入了所有其他 td表的元素偏向一侧。

最佳答案

转您的 <td>进入 <td colspan="6"> (或者你的表格有多少列)。

您实际上是将一个巨大而宽的元素插入表格的第一列。使用 colspan允许表格单元格使用多列。

关于php - 100% 宽度的表格行位于表格的中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6099697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com