微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css – 绕过覆盖“helvetica”字体系列的@ font-face声明

我有一个书签,可以将小部件插入任何网站的页面.小部件的样式被具有以下CSS @ font-face声明的特定站点破坏:
@font-face {
    font-family: "helvetica";
    src: url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.eot?iefix") format("eot"),url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.woff") format("woff"),url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.ttf") format("truetype"),url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.svg#svgFontName") format("svg");
}

我的bookmarklet插入的小部件到处使用helvetica,在这个网站上看起来很糟糕,因为浏览器将helvetica映射到该名称的@ font-face声明而不是标准的helvetica系统字体.

问题:有没有办法覆盖/绕过这个@ font-face声明或者创建另一个映射到系统helvetica字体的@ font-face声明?

解决方法

除非样式表通过在窗口小部件的样式表之后使用!important引用样式表来覆盖它,否则这可能有效:
@font-face {
    font-family: 'ProperHelvetica'; /* Make a name for the "proper" Helvetica */
    src: local('helvetica'); /* Assign it to the Helvetica font on the user's system */
}
.your-widget {
    font-family: 'ProperHelvetica',helvetica,sans-serif !important; /* Make everything 
in your widget use the "proper" Helvetica and if the user doesn't have it,use the site's helvetica. */
}

原文地址:https://www.jb51.cc/css/215861.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。