gpt4 book ai didi

css - 自定义标签在 ie8 中不起作用

转载 作者:行者123 更新时间:2023-11-28 08:59:30 25 4
gpt4 key购买 nike

我尝试制作自定义标签,以便用户在呈现为 HTML 时可以输入显示红色或粗体等内容的文本,例如,

<rb>text here becomes red and bold</rb> and goes to default here

这在类为“note”的 div 中呈现,我设置了以下 css

.note rb
{
color:Red;
font-weight:bold;
}

它在 ie9、chrome、firefox 中工作,但在 ie8 中不工作。我怎样才能让它在那里工作?

最佳答案

如果你不介意一点javascript:

<!--[if lt IE 9]>
<script>
document.createElement("rb");
</script>
<![endif]-->

如果你想添加多个元素/标签,你可以:

<!--[if lt IE 9]>
<script>
// bold, italic, underlined, striked
els = ['rb', 'ri', 'ru', 'rs'];
for(i = 0; i < els.length; i++) {
document.createElement(els[i]);
}
</script>
<![endif]-->

更新

看起来定义自定义元素的能力正在开发中(W3C Working Draft 6 June 2013)

一些使用它的元素:

另见:

关于css - 自定义标签在 ie8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6854757/

25 4 0