CSS3的文字与字体

Author: 刘老师(Aaron Lau) 武汉长乐教育,武汉PHP培训课程,版权所有,转载请注明!

CSS3的文字与字体

课程概要

  1. 文本阴影 text-shadow
  2. 溢出文本 text-overflow, 用(...)省略标记.
  3. 嵌入字体 @font-face

1. 文本阴影 text-shadow

其实与阴影一样

text-shadow: X轴偏移量 Y轴偏移量 模糊半径 阴影颜色

注意: 1.color可以使用rgba色. 2.没有inset

<style type="text/css">
.demo {
    width: 340px;
    padding: 30px;
    font: bold 55px/100% "微软雅黑";
    color: #566F89;
    background: #000;
    text-shadow: 2px 2px 0 #E4F1FF;
}
</style>

<div class="demo">IMOOC</div>

2. 溢出文本 text-overflow, 用(...)省略标记.

text-overflow:clip;        /*表示剪切*/
text-overflow:ellipsis; /*表示显示省略标记*/
<style type="text/css">
.test_demo{
    text-overflow:ellipsis;
    overflow:hidden;
    white-space:nowrap;       /*强制文本在一行内显示*/
    width:200px;
    background:#ccc;
}
</style>

<div class="test_demo">
  超酷的IT技术学习平台(我是省略号)
</div>

3. 嵌入字体 @font-face

<style type="text/css">
@font-face {
    font-family: "MOOC Font";
    src: url("http://www.whphp.com/monaco.otf");
}
.demo {
    width: 340px;
    padding: 30px;
    color: #566F89;
    background: #000;
    font-size:58px;
    font-family: "monaco";
}
</style>

<div class="demo">IMOOC</div>
上一篇课程 下一篇课程

学生登录