内联样式被忽略

发布于 2024-08-24 19:28:18 字数 291 浏览 13 评论 0原文

我的表格中有一个相当简单的单元格,具有内联样式:

<td style="text-align: right;"> Current Status: </td>

并且在 Firefox 和 Opera 中,text-align-right 都被忽略。我使用了 Firefox 的“firebug”,它显示了

知道会发生什么吗?我认为以这种方式指定的内联样式比任何链接样式表或继承样式具有最高优先级。

一如既往地感谢。

I have a fairly simple cell in a table with an inline style:

<td style="text-align: right;"> Current Status: </td>

And the text-align-right is being ignored, both in Firefox and Opera. I used Firefox's "firebug", and it shows me <td style=""> for this.

Any idea what could be going on? I thought that an inline style specified this way took highest priority over any linked style sheet or inherited style.

Thanks as always.

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

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

发布评论

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

评论(5

我的影子我的梦 2024-08-31 19:28:18

通常,当样式声明出现错误时,Firebug 会执行此操作。

Usually Firebug does that when there is an error with the style declaration.

吹泡泡o 2024-08-31 19:28:18

有多种方法可以测试这里发生的情况。在 FireBug 中处理 CSS 类并启用和禁用样式,直到获得预期的结果。显然存在一些样式声明错误,导致该特定样式失败。因为您是对的,内联样式优先于外部样式表和父样式。既然您知道这一点,请重点关注 HTML 的表格区域,看看是否存在任何语法错误、覆盖该值的脚本等。

还要测试不同的文本样式这个“td”标签来查看其他样式是否有效,例如:

color: blue;
line-height: 10px;
letter-spacing: 5px;

另请注意,如果方向属性为默认值“ltr”(从左到右),则 text-align:left 是默认值。因此,此 HTML 表格元素的某些样式可能没有被应用。

There are numerous ways to test what is going on here. Work through your CSS's classes in FireBug and enable and disable styles until you get a result your expecting. There is obviously some style declaration error some where that is causing this particular style to fail. Because you are right, inline styles take priority over external style sheets, and over parent styles. Since you know this focus on the table area of your HTML and see if there are any syntax errors, scripts that are overriding the value, etc.

Also test different text styles for this "td" tag to see if other styles work, such as:

color: blue;
line-height: 10px;
letter-spacing: 5px;

Also note that text-align:left is a default value if the direction property is "ltr" (left to right) which is default. So it could be possible that some of your styles for this HTML table element are not being applied.

淡淡離愁欲言轉身 2024-08-31 19:28:18

而不是您尝试添加一个 span ,它会遵守 text-align ,而 td 不会

<td><span style="text-align: right;">Current Status:</span></td>

Instead of what you have try adding a span which will obey the text-align where the td will not

<td><span style="text-align: right;">Current Status:</span></td>
山川志 2024-08-31 19:28:18

(虽然 Firebug 不再存在,但它的功能已合并到 Firefox 中,而 Firefox 仍然可以表现出 style="" 行为。)

请务必检查开发控制台,因为如果这是由以下原因引起的,则可能会列出错误内容安全策略 (CSP) 设置/限制。

CSP 设置可以通过 Web 服务器 HTTP 响应中的 Content-Security-Policy 标头指定,也可以使用

(While Firebug no longer exists, it's capabilities were folded into Firefox which can still exhibit the style="" behaviour.)

Make sure to check the dev console as there might be errors listed if this is caused by Content-Security-Policy (CSP) settings/restrictions.

CSP settings can either be specified by a Content-Security-Policy header in the web server's HTTP response, or they can be added with a <meta http-equiv="Content-Security-Policy" ...> tag in the HTML (or browser extensions can also enable them on your page).

苦行僧 2024-08-31 19:28:18

我认为您无法在 td 标记内指定文本对齐方式。但是,您可以像这样设置 td 内容的对齐方式:

<td align="right"> Current Status: </td>

I don't think you can specify text alignment within a td tag. However, you can set the alignment of the contents of the td like this:

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