2012-07-27 101 views
0

我是cufon的新手,我在面試中遇到了一些問題。我試圖讓cufon與我的html一起工作。我正在嘗試一個基本腳本(如將h1標籤更改爲不同的字體)。獲取一個簡單的cufon腳本來工作

例子:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
    <script type="text/javascript" src="{{STATIC_URL}}js/cufon-yui.js"></script> 
    <script type="text/javascript"> 
     Cufon.replace('h1',{font-family: "Tahoma"}); 
    </script> 

h1標籤似乎並沒有改變。不知道錯誤在哪裏。我已經包含了jquery lib,cufon js,但它不起作用。需要一些指導..謝謝...

回答

1

您需要使用上http://cufon.shoqolate.com/generate/的工具,你要使用到一個js文件中的字體轉換。

在此之後,你只需要鏈接到它(假設你想使用宋體和{{STATIC_URL}}被變成了正確的路徑):

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script type="text/javascript" src="{{STATIC_URL}}js/cufon-yui.js"></script> 
<script type="text/javascript" src="{{STATIC_URL}}js/tahoma.js"></script> 
<script type="text/javascript"> 
    Cufon.replace('h1'); 
</script> 

不要忘了剛剛閉幕</body>之前添加<script type="text/javascript"> Cufon.now();</script>標籤,使IE的行爲。更多信息可以在https://github.com/sorccu/cufon/wiki/Usage找到。

相關問題