如何让颜色在 sIFR 3 r436 中发挥作用?
我有一个演示页面;您可以查看源代码以了解我正在尝试做什么。
正如您所看到的,除了颜色之外,一切似乎都正常。我试图将颜色设置为蓝色(#0000ff),但它仍然是黑色。我为我的字体创建了一个自定义 SWF 文件,嵌入了单一字体的四种不同变体,以便适应每个 这些说明(因为此特定字体系列将常规、粗体、斜体和粗斜体存储为四种不相交的字体名称)。
为了便于后代,我将粘贴我链接到此处的演示页面中的一些源代码:
<style type="text/css">
h1.sifr {
color: #0000ff;
font-family: 'Myriad Pro';
font-size: 1.75em;
margin-bottom: 0;
}
</style>
<script type="text/javascript">
var myriad_pro = {src: 'myriad_pro.swf'};
sIFR.activate(myriad_pro);
sIFR.replace(myriad_pro, {
selector: 'h1.sifr',
css: {
'.sIFR-root': {'color': '#0000ff', 'font-family' : 'Myriad Pro'},
'em': {'color': '#0000ff', 'font-family' : 'Myriad Pro Italic' , 'font-style' : 'plain'},
'strong': {'color': '#0000ff', 'font-family' : 'Myriad Pro Bold' , 'font-weight' : 'normal'},
'em strong, strong em': {'color': '#0000ff', 'font-family' : 'Myriad Pro Bold Italic' , 'font-style' : 'plain', 'font-weight' : 'normal'}}
}
);
</script>
我忘记了什么?如何让颜色发挥作用?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在这里让它工作。唯一的区别是我的 sifr 文本包含在链接中,并且鼠标悬停时它会改变颜色。
我的脚本如下所示:
希望有帮助。
/克劳斯
I got it working here. The only difference is that my sifr text is inclosed in links, and it changes color on mouse hover.
My script looks like this:
Hope it helps.
/Klaus
您可能需要将颜色值大写,难道不应该是
font-style: normal
而不是plain
吗?You might need to uppercase the color values, and shouldn't it be
font-style: normal
rather thanplain
?好吧,对不起各位。事实证明我只是想太多了。最后,我最终重新导出了我的 SWF 文件(我想我第一次可能做得有些不正确)并显着降低了我的 JavaScript。我仍然在 Flash 文件中包含了所有“四种”字体的嵌入副本 - 我将主动态文本框设置为 Myriad Pro/Regular,然后创建了另外 3 个动态文本框(其中没有文本)设置为粗体分别为 、斜体和粗体斜体。然后,我确保在所有字符上单击“字符嵌入”,并确保包含我想要的字符。
最后,我的 JavaScript 看起来像这样:
我不必更改字体或任何内容,但我仍然必须确保所有四个都包含在 Flash 文件中。回想起来,当我说
font-family: "Myriad Pro Italic"
等时,它确实起作用了,这似乎有点奇怪,因为从技术上来说,这不是字体名称。但无论出于何种原因导致与颜色的冲突,所以当我只是将其称为普通的旧“Myriad Pro”并让它找出斜体和粗体时,一切都起作用了。 @Mark - 小写/大写颜色十六进制代码并不重要。然而,它确实必须是完整的6位十六进制代码(即#00f不起作用)。Ok, sorry guys. It turns out I was just over-thinking this way too much. In the end I ended up re-exporting my SWF file (I think I might have done it somewhat improperly the first time) and dumbing down my JavaScript significantly. I still included an embedded copy of all "four" fonts in the Flash file--I set the main dynamic text box to Myriad Pro/Regular, and then I created 3 more dynamic text boxes (with no text in them) set to Bold, Italic, and Bold Italic respectively. Then I made sure to click "Character Embedding" on all of them and ensure the characters I wanted were included.
Finally my JavaScript ended up looking like this:
I didn't have to change the fonts or anything, but I did still have to make sure all four got included in the Flash file. Looking back it seems a bit odd that it did work when I said
font-family: "Myriad Pro Italic"
, etc., since that isn't technically the font name. But for whatever reason that caused the conflict with the colors, so when I just referred to it as plain old "Myriad Pro" and let it figure out the italicizing and bolding, then it all worked. And @Mark - the lowercase/uppercase color hex codes don't matter. However it does have to be the full 6-digit hex code (i.e. #00f won't work).