(5)CSS文本伪类

(1)first-letter伪类

用于指定只应用于元素第一个字母的规则。该规则通常用于文章新页面的第一个字符。

(2)first-line伪类

用于指定段落第一行与段落其它部分使用不同的格式。


两个伪类的使用方式通常为:(需要注意的是类名后紧跟“:”,“:”后紧跟伪类名,不要添加空格)

.类名:first-line { ... }    和      .类名:first-line { ... }


CSS代码如下:

.cc:first-line { font-weight: bold; }
.cc:first-letter { font-size: 34px; }
HTML代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
	<head>
		<meta charset="utf-8" />  
		<base href="/testsmarty/templates/"></base>
		<title>文本伪类</title>
		<link rel="stylesheet" type="text/css" href="text3.css">
	</head>
	
	<body>
		<fieldset>
			<legend>没使用伪类的效果:</legend>
			<p>The CSS WG published two Candidate Recommendations: CSS Writing Modes Level 3 and CSS Shapes Module Level 1; an updated Working Draft: CSS Lists and Counters Module Level 3; and an update to a Recommendation (editorial changes only): CSS Namespaces Module Level 3.</p>
		</fieldset>
		<fieldset>
			<legend>first-letter与first-line</legend>
			<p class="cc">The CSS WG published two Candidate Recommendations: CSS Writing Modes Level 3 and CSS Shapes Module Level 1; an updated Working Draft: CSS Lists and Counters Module Level 3; and an update to a Recommendation (editorial changes only): CSS Namespaces Module Level 3.</p>
		</fieldset>
	</body>
</html>
效果图如下:


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值