如何用Cufon调整字体大小?

发布于 2024-10-17 07:51:57 字数 1029 浏览 1 评论 0原文

我在 Cufon 中使用压缩字体。当页面加载时,我的菜单太宽并且换行。然后Cufon替换了字体,看起来就不错了。为了减少视觉干扰,我想将字体大小设置得较小,然后让 Cufon 在显示时更改字体大小。

当前字体大小由包含菜单的 div 设置。这是菜单容器的 CSS:

.header_menu_block
{
    display: block;
    margin: 0px 0px 0px 0px;
    padding: 0px 0px 0px 0px;
    margin-top: 3px;
    /*margin-left: 238px;  ie 6 can't handle, see margin block below*/
    float: left;
    text-align: left;
    font-weight: normal;
    font-size: 14px;
    color: #FFFFFF;
    height: 41px;  
    width: 991px;
}

Cufon 替换代码如下所示:

<script type="text/javascript">
    Cufon.replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'}
    } );
</script> 

我尝试将 CSS 字体大小设置为 12px,然后使用以下 Cufon 代码,但它不起作用:

<script type="text/javascript">
    Cufon.replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'},
      font-size:'14px'
    } );
</script>

有谁知道如何做到这一点?

I am using a condensed font in Cufon. When the page loads, my menu is too wide and wraps. Then Cufon replaces the font and it looks fine. To reduce the visual distraction, I want to set the font size smaller and then have Cufon change the font size when it displays.

Currently the font size is set by the div containing the menu. Here is the CSS for the menu container:

.header_menu_block
{
    display: block;
    margin: 0px 0px 0px 0px;
    padding: 0px 0px 0px 0px;
    margin-top: 3px;
    /*margin-left: 238px;  ie 6 can't handle, see margin block below*/
    float: left;
    text-align: left;
    font-weight: normal;
    font-size: 14px;
    color: #FFFFFF;
    height: 41px;  
    width: 991px;
}

The Cufon replacement code looks like this:

<script type="text/javascript">
    Cufon.replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'}
    } );
</script> 

I've tried setting the CSS font size to 12px and then using the following Cufon code, but it does not work:

<script type="text/javascript">
    Cufon.replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'},
      font-size:'14px'
    } );
</script>

Does anyone know how to do this?

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

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

发布评论

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

评论(3

绻影浮沉 2024-10-24 07:51:57

您可以尝试使用 set() 方法。我发现这有效。

<script type="text/javascript">
    Cufon.set('fontSize', '14px').replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'}
    } );
</script>

尽管手册明确建议不要使用字体大小。

https://github.com/sorccu/cufon/wiki/API

You could try using the set() method. I find that this works.

<script type="text/javascript">
    Cufon.set('fontSize', '14px').replace('.header_menu_block_col_menu ', 
    { color: '#ffffff', 
      hover: {color: '#204966'}
    } );
</script>

Although the manual explicitly suggests not using the font size.

https://github.com/sorccu/cufon/wiki/API

时光是把杀猪刀 2024-10-24 07:51:57

让我猜猜,在非 IE 浏览器中你永远看不到底层字体,对吧?非cufon首先在IE中短暂出现?我一直在处理同样的问题,我通过使用 jQuery 让带有文本的 div 淡入视图来解决它。淡入淡出时间可以设置得非常快——在本例中为-200ms,我认为你可以让它淡入得更快。

 $(window).load(function(){$(".header_menu_block_col_menu").fadeIn(200);});

不要忘记设置要显示的 div 的 CSS:none 以便淡入正常工作...
当然,如果您的查看器禁用了 Javascript,则不会显示任何内容 - 但是您网站的访问者禁用 js 的百分比是多少?

并且,担心你的 Google 排名与显示:无? 详细了解 Google 网上论坛

Let me guess, you never see the underlying font in non-IE browsers, right? The non-cufon appears briefly first in IE? I've been dealing with the same issue and I solved it by having the div with the text fade into view with jQuery. The fade time can be set to appear very fast--200ms in this example, I think you can make it fade-in even faster.

 $(window).load(function(){$(".header_menu_block_col_menu").fadeIn(200);});

Don't forget to set the CSS for that div to display:none for the fade-in to work...
Of course, if your viewer has Javascript disabled, then nothing will appear--but what percentage of visitors to your web site have js disabled?

And, worried about your Google ranking with display:none? Read more on Google Groups.

做个ˇ局外人 2024-10-24 07:51:57

我改变了我的CSS,如下所示

.cufon-active h1 { /* for Cufon.replace(‘h1′) */
  font-size: 3em;
  color: #FF0000;
}

I did it changing my CSS as below

.cufon-active h1 { /* for Cufon.replace(‘h1′) */
  font-size: 3em;
  color: #FF0000;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文