不正确的例子
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
正确的例子
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
first-letter与first-line
顾名思义,first-letter就是第一个字母,first-line是第一行文字,它们是少有的被所有主流浏览器支持的CSS 2.1 伪元素,你可以为它们定义任意样式。
示例代码
#demo5{ width:400px;}
#demo5:first-letter{ font-size:32px;color:green}
#demo5:first-line{color:red;}
前端观察 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
前瞻 – CSS3
已经有一部分很棒的CSS3特性可以用到你的设计中了。当然这些中的一部分新属性还不能用于IE,但是你或许了解这对IE来说是常事儿,所以你不妨试试。
@Font-face
@font-face允许你上次一个字体文件到你的网站服务器并将其引入到你的外部CSS文件中,然后就可以将它应用到你的网站的任何文字上。
这是处理文字的最大的功能,但是随之而来的是它的负面效果。由于版权问题,只有少数的字体“被允许”使用。这些字体也就是CSS3安全就在这里里面提到的。当然,对于中文字体来说,除了版权问题,还有网速的问题,一般中文字体动辄几MB的大小,字体文件下载到浏览器就要几分钟,这对于用户来说是不划算的。
使用@font-face
在这个例子中我在我的网站的根目录下放了一个font文件夹,然后将需要用到的字体放入该文件夹。你首先需要声明@font-face 属性以导入你的字体文件,然后使用该字体名称来控制其它元素的字体。
/* 声明字体 */
@font-face {
src:(font/diavlo.otf)
}
/* 将改字体应用到一个元素 */
h1 {font-family: diavlo, Arial;
}
Text-Shadow
text-shadow属性赶走了用Photoshop为某些元素制作下拉阴影的需求,并给你提供动态的阴影控制。当然,该属性IE并不支持。
示例标题
p {
font-size: 2em;
font-weight: bold;
color: #777;
text-shadow: 1px 1px 1px #222;
}
示例标题2
p {text-shadow: 2px 2px 2px #222;}
示例标题3
p {text-shadow: 1px 1px 5px #FFF;}
PS:呃,其实前端观察的文章标题和章节的二级标题都用了text-shadow,而且还是用了更漂亮的RGBa颜色。