jQuery Cufon 行高问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2088798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:44:27  来源:igfitidea点击:

Cufon line-height problem

jquerycssfonts

提问by Efe Tuncel

When I apply line-height in CSS or in javascript, it does not do it. And if I apply in the script, I get the following error.

当我在 CSS 或 javascript 中应用 line-height 时,它不会这样做。如果我在脚本中申请,我会收到以下错误。

Error: missing : after property id
Line: 26, Column: 44
Source Code:
Cufon.replace('#header .lists li a', {line-height: '120%;', font-size: '120%'}); 

javascript

javascript

$(document).ready(function() 
{

    Cufon.replace('#header .lists li a', {line-height: '120%;', font-size: '120%'});

});

style.css

样式文件

#header .lists { float:left; position:relative; width:776px; height:40px; list-style:none; padding:0; margin:0; margin-top:1px; background:url(../images/bg_mainmenu_off.gif); z-index:100; }
#header .lists li {float:left; height:40px; display:inline; background:url(../images/bg_mainmenu_off.gif) repeat-x;}
#header .lists li a {display:block; width:150px; height:40px; line-height:40px; text-decoration:none; font-size:16px; font-weight:bold; text-indent:10px; font-weight:bold; color:#FFFFFF; margin: 0px; }
#header .lists li a:hover { background:url(../images/bg_mainmenu_on.gif) repeat-x; }
#header .lists div {display:none; }
#header .lists :hover div {display:block; position:absolute; background:#FFFFFF; top:26px; border:1px solid #ece7d1; padding-bottom:10px;}
#header .lists :hover div dl { float:left; width:179px; display:inline; padding:5px; margin:0 5px 10px 5px;}
#header .lists :hover div dl dt { width:179px; height:16px; background:#b39f87; margin:5px 0 10px 0; text-decoration:none; }
#header .lists :hover div dl dd {padding:0; margin:0;}
#header .lists :hover div dt a { display:block; height:14px; line-height:14px; font-size:14px; color:#FFFFFF; font-weight:bold; text-decoration:none;}
#header .lists :hover div dt a:hover { background:none;}
#header .lists :hover div dd a { display:block; height:14px; line-height:14px; font-size:14px; color:#b39f87; font-weight:normal; text-decoration:none; }
#header .lists :hover div dd a:hover {text-decoration:underline; background:none;}

回答by Josh Stodola

There is a known bug in Cufon that will probably not be fixedregarding flaky line-height recognition on pages with non-strict doctypes.

Cufon 中存在一个已知错误,该错误可能无法修复关于具有非严格文档类型的页面上的片状行高识别。

回答by Silvan

Also the following CSS styling worked for me without Doctype change (like the post from Keith before)

以下 CSS 样式也适用于我,无需更改 Doctype(如 Keith 之前的帖子)

div#navigation ul li cufon {
    padding-bottom: 3px;
}

Cheers

干杯

回答by sweet_grass

One solution we (@markedupactually) have found is to wrap a span around the text inside the element you are having issues with, so:

我们(实际上是@markedup)找到的一种解决方案是在您遇到问题的元素内的文本周围环绕一个跨度,因此:

<h1><span>Some text here that is giving you a bit of a headache</span></h1>

Add bottom padding on the child span and bob's your mothers brother.

在孩子跨度上添加底部填充物,鲍勃是你母亲的兄弟。

Uses a bit of extra code but better than specifying the wrong doctype, resulting in potential invalid pages and b0rked css.

使用一些额外的代码,但比指定错误的文档类型要好,这会导致潜在的无效页面和 b0rked css。

Cheers.

干杯。

回答by The coder of salvation

I can't help to mention:

我不禁提到:

{line-height: '120%;',

you might want to change this into:

你可能想把它改成:

{'line-height': '120%',

since javascript parsers might break on the '-' operator..

因为javascript解析器可能会在'-'运算符上中断..

回答by Sedat Kumcu

I've solved the problem as follows. Cufon creates <cufon>tags at document ready. I define a CSS style like this in my .css document. (my cufon Text in the .HeaderArea class)

我已经解决了以下问题。Cufon<cufon>在文档准备好时创建标签。我在我的 .css 文档中定义了这样的 CSS 样式。(我在 .HeaderArea 类中的 cufon 文本)

.HeaderArea cufon { margin-bottom:10px; }

回答by Michael Giovanni Pumo

I know I might be a little late to the cufon party, but I read some of the solutions using margin, above. I tried this, but in my case, I needed a "tighter" line-height. I tried a negative value but it still didn't work. I figured out that you need to display the cufon generated tag's to block.

我知道我参加 cufon 派对可能有点晚了,但我阅读了上面使用边距的一些解决方案。我试过这个,但就我而言,我需要一个“更紧”的行高。我尝试了一个负值,但它仍然不起作用。我发现您需要显示要阻止的 cufon 生成的标签。

Here's a code snippet:

这是一个代码片段:

.myClass cufon { display: block; float: left; margin-top: -3px!important; }

This seems to work a treat.

这似乎是一种享受。

Good luck out there. It's a dangerous world.

祝你好运。这是一个危险的世界。

回答by popware

This works for me:

这对我有用:

## main-content .cufon-canvas {height: 25px !important;}

回答by Jeroen

For the people who are still looking for an answer.
Every word is separated by Cufon in block elements

对于仍在寻找答案的人。
每个单词在块元素中用 Cufon 分隔

So try this:

所以试试这个:

.yourCufonDiv .cufon-canvas {margin-bottom:5px;}

回答by user3151705

For line-height to work with Cufon, you need to change the above into the Strict DOCTYPE

要使 line-height 与 Cufon 一起使用,您需要将上述内容更改为 Strict DOCTYPE

Visit:http://xsdesigns.se/2012/08/not-just-seo-but-a-little-bit-of-coding-tips-as-well-cufon-fonts-and-line-height-problem-fix/

访问:http: //xsdesigns.se/2012/08/not-just-seo-but-a-little-bit-of-coding-tips-as-well-cufon-fonts-and-line-height-problem-使固定/