📄 pr_pseudo_first-letter.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS :first-letter pseudo-element</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<style type="text/css">
div.ex:first-letter
{
color: #ff0000;
font-size:xx-large
}
</style>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>CSS :first-letter pseudo-element</h1>
<hr />
<a href="css_reference.asp"><img class="navup" src="../images/up.gif" alt="CSS Reference" border="0" /> Complete CSS Reference</a>
<hr />
<h2>Definition</h2>
<p>The :first-letter pseudo-element adds a special style to the first letter of a text.</p>
<h2>Examples</h2>
<p>The "first-letter" pseudo-element is used to add special style to the first
letter of the text in a selector:</p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table6"><tr><td>
<pre>p {font-size: 12pt}
p:first-letter {color:#ff0000;font-size:xx-large}</pre>
<pre><p>The first words of an article...</p></pre>
</td></tr></table>
<p>The output could be something like this:</p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table7"><tr><td>
<div class="ex">The first
words of an
article...</div></td></tr></table>
<p><b>Note:</b>
The "first-letter" pseudo-element can only be used with block-level elements.</p>
<p><b>Note:</b> The following properties apply to the "first-letter" pseudo- element: </p>
<ul>
<li> font properties</li>
<li> color properties </li>
<li> background properties</li>
<li>margin properties</li>
<li>padding properties</li>
<li>border properties</li>
<li>text-decoration</li>
<li>vertical-align (only if 'float' is 'none')</li>
<li>text-transform</li>
<li>line-height</li>
<li>float</li>
<li>clear</li>
</ul>
<p>
Pseudo-elements can also be combined with CSS classes: </p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table8"><tr><td>
<pre>p.article:first-letter {color: #FF0000}</pre>
<pre><p class="article">A paragraph in an article</p></pre>
</td></tr></table>
<p>The example above will set the first letter of all paragraphs with class="article"
to red.</p>
<hr />
<h2>Try-It-Yourself Demos</h2>
<p><a target="_blank" href="tryit.asp@filename=trycss_firstletter">Make the first letter special</a><br />
This example demonstrates how to add a special effect to the first
letter of a text.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_firstline_letter">Make the
first letter and first line special</a><br />
This example demonstrates how to add a special effect to the first letter and
the first line of a text.</p>
<hr />
<a href="css_reference.asp"><img class="navup" src="../images/up.gif" alt="CSS Reference" border="0" /> Complete CSS Reference</a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -