CSS伪对象搞定首字下沉

导读:   用过word,看过报纸的朋友,是不是对它们的首字下沉效果很感兴趣?  

有的时候适当的在web中使用些首字下沉的效果,能为你的web增色不少。   

通过伪对象:first-letter可以搞定这个效果:   

CSS部分:   

.dyfirst {   width:300px;   border:1px solid #ddd;   padding:5px;   font-size:12px;   }   

.dyfirst:first-line {   color:#050;   }   

.dyfirst:first-letter {   font-size:300%;   font-weight:bold;   color:#000;   float:left;   }   

XHTML部分:   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html> <head>

<meta http-equiv="content-type" content="text/html; charset=gb2312" />

<meta name="Author" content="飘零雾雨|edzmaster@gmail.com" />

 <title>CSS Pseudo-Elements 搞定首字下沉</title>

</head>

<body>

<div class="dyfirst"> To the world you may be one person, but to one person you may be theworld. Never frown, even when you are sad, because you never know who is fallingin love with your smile. </div>

</body> </html>       

以上的CSS只有.dyfirst:first-letter是用来做首字下沉效果的,其余的两个东东,只是为了让这个效果看起来更明显。同时也把:first-line的用法写了下,毕竟和:first-letter是“胞兄弟”,称不离砣嘛。   

用CSS Pseudo-Elements做首字下沉的原理大致就是这样的,这只是一个演示,朋友们可以把效果做得更赞。

本文转自 http://blog.doyoe.com/article.asp?id=15

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值