freecodecamp.cn icon indicating copy to clipboard operation
freecodecamp.cn copied to clipboard

导入Lobster字体。尝试使用link @font-face都不能正确通过挑战,请问是哪里问题

Open wangzhenalex opened this issue 10 years ago • 11 comments

Challenge Import a Google Font has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

<link href="https://fonts.gdgdocs.org/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
  h2 {
     font-family: Lobster;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">在大家心目中,猫是慵懒的可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。</p>
<p class="red-text">养动物有的时候,就是介于爱与恨之间,当你钦羡别人萌宠这么可爱的时候,你一定没有想过,狗狗和猫猫会到处拉屎,甚至会屯老鼠,啃鞋子,用爪子爬门,你不理它,它就挠你,你要对它发脾气,它会比你更来劲。所以,狗猫慎入,没有一定的准备,切勿随便去侍养动物。它们一旦认定你了,你就是它们的主人,如果你抛弃它们,它们必定心中重创。</p>

wangzhenalex avatar Nov 10 '16 05:11 wangzhenalex

把链接换成这个就可以了。 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lobster">

AI-Ying avatar Nov 10 '16 11:11 AI-Ying

为什么文中提到的链接不行呢?你的这个链接的内容跟文中提到的链接的网页内容好像是一样的呀?

pbxrt avatar Nov 10 '16 14:11 pbxrt

在chrome下,题目里面按F12,调出Dev Tools。检查Sources,可以发现challenges/import-a-google-font里面有一行:

common.tests = 
  ["assert(new RegExp(\"googleapis\", \"gi\").test(code), 'message: 导入<code>Lobster</code>字体。');",
  "assert($(\"h2\").css(\"font-family\").match(/lobster/i), 'message: 你的副标题应该使用字体<code>Lobster</code>。');",
  "assert($(\"p\").css(\"font-family\").match(/monospace/i), 'message: 你的段落仍旧使用字体<code>Monospace</code>。');
  "];

说明这一题的第一个条件会检测做题人的整份代码里面是否包含googleapis,所以这个是一个bug。可以换链接,也可以在任意地方加上googleapis字样,就可以通过了。

mougua avatar Nov 10 '16 15:11 mougua

@mougua 感谢你的回答。 因为谷歌字体在中国的不稳定情况,偶尔能用,偶尔又不能用。 所以我们把谷歌字体替换为了GDG字体,当然,GDG只是一个代理,实际上的字体存在七牛云上。 但测试部分忘记更改了,为了兼容大家喜好。此处会修改为:

assert(new RegExp(\"googleapis|gdgdocs\", \"gi\").test(code)

huluoyang avatar Nov 11 '16 08:11 huluoyang

为什么我的还是不可以啊,换了上面这个Link也不行啊

Shisanyue8023 avatar Nov 15 '16 11:11 Shisanyue8023

我的代码用开始的的链接的话,h2 标签可以正常显示新字体,但是应用在p标签上就不行。这到底是怎么回事?奇了怪了。如果换成大家说的googleapi这个链接根本不起作用,连h2标签都不能正常显示了。我用的是360安全浏览器极速模式,电信网络

wlxfx avatar Dec 17 '16 08:12 wlxfx

学前端,我建议用Chrome 浏览器,各种牛逼不解释

发自网易邮箱大师 在2016年12月17日 16:04,网络小飞侠 写道:

我的代码用开始的的链接的话,h2 标签可以正常显示新字体,但是应用在p标签上就不行。这到底是怎么回事?奇了怪了。如果换成大家说的googleapi这个链接根本不起作用,连h2标签都不能正常显示了。我用的是360安全浏览器极速模式,电信网络

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

xuezechao2012 avatar Dec 17 '16 08:12 xuezechao2012

就算用chrome 不能翻墙也没用啊,chrome我也有,但是一样没反应,不能解决问题。你能不能帮我?如果不能也不用过来炫耀下自己用chrome就走是不是?何必呢?

wlxfx avatar Dec 17 '16 08:12 wlxfx

请贴一下这节课程的标题 #53不太好找

在 2016年12月17日,16:04,网络小飞侠 [email protected] 写道:

我的代码用开始的的链接的话,h2 标签可以正常显示新字体,但是应用在p标签上就不行。这到底是怎么回事?奇了怪了。如果换成大家说的googleapi这个链接根本不起作用,连h2标签都不能正常显示了。我用的是360安全浏览器极速模式,电信网络

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FreeCodeCampChina/freecodecamp.cn/issues/53#issuecomment-267749482, or mute the thread https://github.com/notifications/unsubscribe-auth/ARPzkEHu_R5UbSTidPJ6tvjSgpLZt8P-ks5rI5eWgaJpZM4KuSbf.

Rockelbel avatar Dec 18 '16 00:12 Rockelbel

这里不管p标签,只需单独写 h2 { font-family:Lobster;}

sausagehwx avatar Feb 12 '17 16:02 sausagehwx

CatPhotoApp

在大家心目中,猫是慵懒的可爱的化身,它,怎能不惹人怜爱。

养动物有的时候,就是介心中重创。

没错吧?为什么P标签字体还是没有变化?!

chipchh avatar Jun 26 '17 02:06 chipchh