Opera 和 IE 无法正确归因 ​​css 文本装饰

发布于 2024-10-07 23:18:38 字数 771 浏览 0 评论 0原文

使用 Opera 11 和 IE 9,这两个浏览器似乎没有正确归属 CSS 文本装饰样式。这在 Chrome、FireFox 和 Safari 中 100% 有效。有人对如何解决这个问题有建议吗?

错误的效果:

alt text

正确的效果:

alt text

这是 CSS:

#main_title {
    font-size: 18px;
    color: #000;
    font-weight: bold;
}

#main_title a {
    color: #000;
}

#main_title_accent {
    border: 1px solid #000;
    background: #ff9935;
    text-decoration: none;
    font-size: 20px;
    padding: 5px;
}

这是 HTML:

<div id="main_title">
    <a href="home">Text <span id="main_title_accent">Goes</span> Here</a>
</div>

Using Opera 11 and IE 9, it seems that these two browsers do not attribute the CSS text-decoration style correctly. This works 100% in Chrome, FireFox and Safari. Does anyone have a suggestion on how to fix this?

The Wrong Effect:

alt text

The Right Effect:

alt text

Here's the CSS:

#main_title {
    font-size: 18px;
    color: #000;
    font-weight: bold;
}

#main_title a {
    color: #000;
}

#main_title_accent {
    border: 1px solid #000;
    background: #ff9935;
    text-decoration: none;
    font-size: 20px;
    padding: 5px;
}

And this is the HTML:

<div id="main_title">
    <a href="home">Text <span id="main_title_accent">Goes</span> Here</a>
</div>

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

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

发布评论

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

评论(1

说好的呢 2024-10-14 23:18:38

您需要将 display:inline-block 赋予 #main_title_accent

了解更多信息,请访问 w3c: 16.3.1 - text-decoration 属性

相关报价

请注意,文本装饰不是
传播到浮动和绝对
定位后代,也不是
原子内联级的内容
后代例如内联块
内联表。

实例:http://jsfiddle.net/qp32H/1/

You need to give display:inline-block to the #main_title_accent.

Read more at w3c: 16.3.1 - text-decoration property

Relevant quote

Note that text decorations are not
propagated to floating and absolutely
positioned descendants, nor to the
contents of atomic inline-level
descendants such as inline blocks and
inline tables.

Live example: http://jsfiddle.net/qp32H/1/

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