欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  把文本的第一个字母设为特殊的字母
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>自学教程(如约智惠.com)</title>
 
  <style>
 
  p:first-letter{
 
  color:#ff0000;
 
  font-size:xx-large;
 
  }
 
  </style>
 
  </head>
 
  <body>
 
  <p>你可以使用"first-letter"伪元素向文本的首字母设置特殊样式;</p>
 
  </body>
 
  </html>
 
  把第一行文字设置为特殊
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>自学教程(如约智惠.com)</title>
 
  <style>
 
  p:first-letter{
 
  color:#ff0000;
 
  font-size:xx-large;
 
  }
 
  </style>
 
  </head>
 
  <body>
 
  <p>你可以使用"first-letter"伪元素向文本的首字母设置特殊样式;</p>
 
  </body>
 
  </html>
 
  把第一行文字的第一个字母设置为特殊
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>自学教程(如约智惠.com)</title>
 
  <style>
 
  p:first-letter{
 
  color:#ff0000;
 
  font-size:xx-large;
 
  }
 
  p:first-line{
 
  color:#0000ff;
 
  font-variant:small-caps;
 
  }
 
  </style>
 
  </head>
 
  <body>
 
  <p>你可以结合使用"first-line"和"first-letter"伪元素向文本的首行和首字母设置特殊样式。</p>
 
  </body>
 
  </html>
 
  使用:在一个元素之前插入一些内容
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>自学教程(如约智惠.com)</title>
 
  <style>
 
  h1:before{content:url(smiley.gif);}
 
  </style>
 
  </head>
 
  <body>
 
  <h1>Thisisaheading</h1>
 
  <p>The:beforepseudo-elementinsertscontentbeforeanelement.</p>
 
  <h1>Thisisaheading</h1>
 
  <p><b>注意:</b>仅当!DOCTYPE已经声明IE8支持这个内容属性</p>
 
  </body>
 
  </html>
 
  使用:在一个元素之后插入一些内容
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <metacharset="utf-8">
 
  <title>自学教程(如约智惠.com)</title>
 
  <style>
 
  h1:after{content:url(smiley.gif);}
 
  </style>
 
  </head>
 
  <body>
 
  <h1>Thisisaheading</h1>
 
  <p>The:beforepseudo-elementinsertscontentbeforeanelement.</p>
 
  <h1>Thisisaheading</h1>
 
  <p><b>注意:</b>仅当!DOCTYPE已经声明IE8支持这个内容属性</p>
 
  </body>
 
  </html>







本文转载自中文网

 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c55504.shtml