6.(初级)web字体之:@font-face

一、web载入字体设置@font-face

1、@font-face设置

!设置时必须在最后加上;(分号),否则@font-face无效

属性:

font-famliy:设置字体名称

src:设置字体文件

例如:

@font-face{

font-famliy:”league Gothic”;

src:url(”font/league_Gothic-web font.woff”);

}

2@font-face兼容性解决方案

@font-face{

设置字体名称

font-famliy:”league Gothic”;

兼容IE9兼容模式

src:url(”font/league_Gothic-webfont.eot”);

兼容IE6~IE8format指明字体格式使浏览器更好的兼容

src:url(”font/league_Gothic-webfont.eot?#iefix”) format(”embedded-opentype”),

      woff2是woff的优化版

      url(”font/league_Gothic-webfont.woff2”) format(”woff2”),

      兼容除IE外浏览器

      url(”font/league_Gothic-webfont.woff”) format(”woff”),

      兼容Safari, Android, iOS

      url(”font/league_Gothic-webfont.ttf”) format(”ttf”),

      url(”font/league_Gothic-webfont.svg”) format(”svg”);

}

使用web字体

h1{

font-family:’league Gothic’;

}

三、web粗体、斜体字体

web字体一般包括:一个常规体,一个粗体,一个斜体,一个粗斜体

1、设置粗体斜体

例如:

@font-face{   指定常规字体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:normal;

font-style:normal;

}

@font-face{   指定粗体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:bold;

font-style:normal;

}

@font-face{   指定斜体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:normal;

font-style:italic;

}

@font-face{   指定粗斜体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:bold;

font-style:italic;

}

!如上设置,只需指定完字体,让浏览器自行判断,<em>、<strong>使用哪种字体

2、设置粗体斜体兼容IE8

@font-face{   指定常规字体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.eot?#iefix) format(embedded-opentype),

      url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:normal;

font-style:normal;

}

@font-face{   指定粗体

font-famliy:league Gothic bold”;

src:url(font/league_Gothic-webfont.eot?#iefix) format(embedded-opentype),

      url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:bold;

font-style:normal;

}

@font-face{   指定斜体

font-famliy:”league Gothic”;

src:url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:normal;

font-style:italic;

}

@font-face{   指定粗斜体

font-famliy:league Gothic boldItalic”;

src:url(font/league_Gothic-webfont.eot?#iefix) format(embedded-opentype),

      url(font/league_Gothic-webfont.woff2) format(woff2),

      url(font/league_Gothic-web font.woff) format(woff);

font-weight:bold;

font-style:italic;

}

四、其他选择符

:target选择符:依赖于ID属性,要使用ID连接到网页中的特定位置

例如:<a href=”#ID”>超链接至form</a>

      <form id=”ID”>XXX</form>

  #ID:target——点击<a>后form成为target

:not()选择符:选取不符合条件的标签

例如:p:not(.aaa)

not()只能使用简单选择符,不能使用情况如下:

1、后代选择符(div p a)。

2、伪元素选择符(:hover)

3、群组或组合选择符(h2 + p)

4、同时使用多个not()选择符( p:not(#ID):not(.class) )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值