如何在polymer 2.x中加载自定义字体
我在加载web字体时遇到问题。我该怎么做如何在polymer 2.x中加载自定义字体,polymer,polymer-2.x,Polymer,Polymer 2.x,我在加载web字体时遇到问题。我该怎么做 @font-face { font-family: 'RobotoCondensed'; font-weight: 400; font-style: normal; src: url('../fonts/rc.eot'); // IE9 Compat Modes */ src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url('..
@font-face {
font-family: 'RobotoCondensed';
font-weight: 400;
font-style: normal;
src: url('../fonts/rc.eot'); // IE9 Compat Modes */
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url('../fonts/rc.eot?#iefix') format('embedded-opentype'), // IE6-IE8 */
url('../fonts/rc.woff2') format('woff2'), // Super Modern Browsers */
url('../fonts/rc.woff') format('woff'), // Modern Browsers */
url('../fonts/rc.ttf') format('truetype'), // Safari, Android, iOS */
url('../fonts/rc.svg#RobotoCondensed') format('svg'); // Legacy iOS */
}
这是我的html导入:
<style>
@font-face {
font-family: 'RobotoCondensed';
font-weight: 400;
font-style: normal;
src: url('../fonts/rc.eot'); // IE9 Compat Modes */
src: local('Roboto Condensed'), local('RobotoCondensed-Regular'), url('../fonts/rc.eot?#iefix') format('embedded-opentype'), // IE6-IE8 */
url('../fonts/rc.woff2') format('woff2'), // Super Modern Browsers */
url('../fonts/rc.woff') format('woff'), // Modern Browsers */
url('../fonts/rc.ttf') format('truetype'), // Safari, Android, iOS */
url('../fonts/rc.svg#RobotoCondensed') format('svg'); // Legacy iOS */
}
</style>
<!-- Dependency resources -->
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/shadycss/apply-shim.html">
<link rel="import" href="../styles/shared-styles.html">
<link rel="import" href="../ui/layout/layout-bundle.html">
<link rel="stylesheet" href="../font.css">
<!-- Defines the example-template element -->
<dom-module id="neg-door">
<template>
<style include="header-view left-view"></style>
<div id="header">
<search-view id="search-view"></search-view>
<locations></locations>
</div>
<div id="left">
<span>left</span>
<category-view id="category-view"></category-view>
</div>
<content-view id="content-view"></content-view>
<div id="right">
<span>right</span>
<my-room></my-room>
</div>
</template>
<!-- Polymer boilerplate to register the example-template element -->
<script>
class NegDoor extends Polymer.Element {
static get is() {
return 'neg-door'
}
}
customElements.define(NegDoor.is, NegDoor);
</script>
</dom-module>
@字体{
字体系列:“RobotoCondensed”;
字体大小:400;
字体风格:普通;
src:url('../font/rc.eot');//IE9兼容模式*/
src:local('Roboto Condensed')、local('robotocdensed-Regular')、url('../font/rc.eot?#iefix')格式('embedded-opentype')、//IE6-IE8*/
url('../fonts/rc.woff2')格式('woff2'),//超级现代浏览器*/
url('../fonts/rc.woff')格式('woff'),//现代浏览器*/
url('../fonts/rc.ttf')格式('truetype'),//Safari、Android、iOS*/
url('../fonts/rc.svg#robotcondensed')格式('svg');//旧版iOS*/
}
左边
正确的
NegDoor.Element类{
静态get是(){
返回“负门”
}
}
customElements.define(NegDoor.is,NegDoor);
这里有一个例子,在头标签之间的index.html
:
<link rel="import" href="src/style.html">
style.html上的一个示例:
<!DOCTYPE html>
<style>
@import url('https://fonts.googleapis.com/css?family=Kaushan+Script');
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');
html,
body {
font-family: 'Roboto', Arial, sans-serif;
height: 100%;
margin: 0;
}
jj-app[unresolved] {
display: block;
background-image: url('../images/beach.jpg')
min-height: 101vh;
line-height: 68px;
text-align: center;
font-size: 16px;
font-weight: 600;
letter-spacing: 0.3em;
color: #202020;
padding: 0 16px;
overflow: visible;
}
#fbui {
position: fixed;
top: 20%;
margin: 10px 10px;
width: 88%;
padding: 10px;
border: 3px solid green;
display: none;
}
</style>
<script>
var importDoc = document.currentScript.ownerDocument;
var style = importDoc.querySelector('style');
document.head.appendChild(style);
</script>
@导入url('https://fonts.googleapis.com/css?family=Kaushan+脚本');
@导入url('https://fonts.googleapis.com/css?family=Roboto+浓缩’);
html,
身体{
字体系列:“Roboto”,Arial,无衬线;
身高:100%;
保证金:0;
}
jj应用程序[未解决]{
显示:块;
背景图像:url(“../images/beach.jpg”)
最小高度:101vh;
线高:68px;
文本对齐:居中;
字体大小:16px;
字号:600;
字母间距:0.3em;
颜色:#202020;
填充:0 16px;
溢出:可见;
}
#fbui{
位置:固定;
最高:20%;
利润率:10px 10px;
宽度:88%;
填充:10px;
边框:3倍纯绿;
显示:无;
}
var importDoc=document.currentScript.ownerDocument;
var style=importDoc.querySelector('style');
document.head.appendChild(样式);