如何让颜色在 sIFR 3 r436 中发挥作用?

发布于 2024-08-13 05:24:55 字数 1237 浏览 7 评论 0 原文

我有一个演示页面;您可以查看源代码以了解我正在尝试做什么。

正如您所看到的,除了颜色之外,一切似乎都正常。我试图将颜色设置为蓝色(#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>

我忘记了什么?如何让颜色发挥作用?

I've got a demo page up here; you can view source to see what I'm trying to do.

As you can see, everything about it seems to be working except for colors. I'm trying to set the color to blue (#0000ff), but it stays as black. I created a custom SWF file for my font, embedding four different variations of a single font in order to accommodate for different styles per these instructions (because this particular font family stores regular, bold, italic, and bold italic as four disjoint font names).

For posterity I'll paste some of the source code from that demo page I linked to here:

<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>

What did I forget? How do I get colors working?

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

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

发布评论

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

评论(3

寻找一个思念的角度 2024-08-20 05:24:55

我在这里让它工作。唯一的区别是我的 sifr 文本包含在链接中,并且鼠标悬停时它会改变颜色。

我的脚本如下所示:

 <script language="javascript" type="text/javascript">
        //sIFR.useStyleCheck = true;
        var eurostile = {
            src: '/images/eurostile.swf'};
        sIFR.activate(eurostile);
        sIFR.replace(eurostile , {selector: "div#mainNav li", wmode: "transparent", 
        css: [
             'a { text-decoration: none; color: #666666; }'
            ,'a:link { color: #666666; }'
            ,'a:hover { color: #00299b; }'
        ]});
        sIFR.replace(eurostile , {selector: "div.menuHeadingText", wmode: "transparent"
        ,css: [
            '.sIFR-root { color: #FFFFFF; }',
            'a { text-decoration: none; color: #FFFFFF; }'
            ,'a:link { color: #FFFFFF; }'
            ,'a:hover { color: #FF5A00; }'
        ]});

        sIFR.replace(eurostile , {selector: "h2.boxHeading", wmode: "transparent"
        ,css: [
            '.sIFR-root { color: #666666; }'
        ]});

希望有帮助。

/克劳斯

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:

 <script language="javascript" type="text/javascript">
        //sIFR.useStyleCheck = true;
        var eurostile = {
            src: '/images/eurostile.swf'};
        sIFR.activate(eurostile);
        sIFR.replace(eurostile , {selector: "div#mainNav li", wmode: "transparent", 
        css: [
             'a { text-decoration: none; color: #666666; }'
            ,'a:link { color: #666666; }'
            ,'a:hover { color: #00299b; }'
        ]});
        sIFR.replace(eurostile , {selector: "div.menuHeadingText", wmode: "transparent"
        ,css: [
            '.sIFR-root { color: #FFFFFF; }',
            'a { text-decoration: none; color: #FFFFFF; }'
            ,'a:link { color: #FFFFFF; }'
            ,'a:hover { color: #FF5A00; }'
        ]});

        sIFR.replace(eurostile , {selector: "h2.boxHeading", wmode: "transparent"
        ,css: [
            '.sIFR-root { color: #666666; }'
        ]});

Hope it helps.

/Klaus

唠甜嗑 2024-08-20 05:24:55

您可能需要将颜色值大写,难道不应该是 font-style: normal 而不是 plain 吗?

You might need to uppercase the color values, and shouldn't it be font-style: normal rather than plain?

情深缘浅 2024-08-20 05:24:55

好吧,对不起各位。事实证明我只是想太多了。最后,我最终重新导出了我的 SWF 文件(我想我第一次可能做得有些不正确)并显着降低了我的 JavaScript。我仍然在 Flash 文件中包含了所有“四种”字体的嵌入副本 - 我将主动态文本框设置为 Myriad Pro/Regular,然后创建了另外 3 个动态文本框(其中没有文本)设置为粗体分别为 、斜体和粗体斜体。然后,我确保在所有字符上单击“字符嵌入”,并确保包含我想要的字符。

最后,我的 JavaScript 看起来像这样:

<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'}
    }
});
</script>

我不必更改字体或任何内容,但我仍然必须确保所有四个都包含在 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:

<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'}
    }
});
</script>

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).

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