文本与CSS转换属性重叠

发布于 2025-01-24 02:47:16 字数 1013 浏览 3 评论 0原文

当我使用

 .right-align {
     text-align: right !important;
     transform: translateX(-40%);
 }

表结构如下所示

<table>
    <thead>
        <tr>
            <th>Bid
            </th>
            <th>Offer
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <div class="right-align">
                    200
                </div>
            </td>
            <td>
                <div class="right-align">
                    221
                </div>
            </td>
        </tr>
    </tbody>
</table>

TD的元素,如下所示,如下所示,

”文本重叠映像“

我如何才能使其在标题下进行?

当桌子滚动时,这正在发生

When I am using

 .right-align {
     text-align: right !important;
     transform: translateX(-40%);
 }

The Table structure is showing below

<table>
    <thead>
        <tr>
            <th>Bid
            </th>
            <th>Offer
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <div class="right-align">
                    200
                </div>
            </td>
            <td>
                <div class="right-align">
                    221
                </div>
            </td>
        </tr>
    </tbody>
</table>

The td is overlapping the th element as seen below

Text overlap image

How can I can make it go under the header ?

This is happening when table is scrolling

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热情消退 2025-01-31 02:47:16

但是,只要您保持代码紧密,就很难回答该问题的比例和结构。

.right-align {
  text-align: right !important;
}
<table>
  <thead>
    <tr>
      <th>Bid</th>
      <th>Offer</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="right-align">200</td>
      <td class="right-align">221</td>
    </tr>
  </tbody>
</table>

为什么您决定使用转换:Translatex(-40%);规则,但似乎您可能正在尝试覆盖主题来自主题的某些规则,因此您是问题,因此您是问题面对;如果您更新问题并添加更多代码或至少您要实现的目标,那么我可能会更有帮助:)。另外,如果您使用的是框架或主题,则指定哪个。

编辑。
我看到了您的更新,您无需在TD元素中添加DIV即可应用类,您可以直接在TD元素中进行。但是,似乎某些CSS规则是重叠的。也许浏览器中结果的屏幕截图可能会有所帮助。

It is very hard to answer the question as it is, however, the table should keep its proportions and structure as long as you keep the code tight:

.right-align {
  text-align: right !important;
}
<table>
  <thead>
    <tr>
      <th>Bid</th>
      <th>Offer</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="right-align">200</td>
      <td class="right-align">221</td>
    </tr>
  </tbody>
</table>

It is nebulous why you decided to use the transform: translateX(-40%); rule in there, but it seems you may be trying to overwrite some rules that come from a theme hence the problem you are facing; If you update your question and add more pieces of code or at least what you are trying to achieve then i could be more helpful :). Also if you are using a framework or theme specify which one.

EDIT.
I saw your updates, you don't need to add a div within the td element to apply a class, you can do it directly in the td element. However, it seems that some css rules are overlapping. Maybe a screenshot of the results in a browser could be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文