Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS伪元素_Css_Pseudo Element - Fatal编程技术网

CSS伪元素

CSS伪元素,css,pseudo-element,Css,Pseudo Element,这段代码解释了伪元素第一个字母和第一行,并且工作正常 <html> <head> <title>Practice CSS :first-letter pseudo element </title> </head> <style type="text/css"> <!-- p:first-letter { font-size: 3em; text-color:red; }

这段代码解释了伪元素
第一个字母
第一行
,并且工作正常

<html>
    <head>
    <title>Practice CSS :first-letter pseudo element </title>
    </head>

    <style type="text/css">
    <!--
    p:first-letter { font-size: 3em; text-color:red; }
    p.normal:first-letter { font-size: 40px; color:red; }

    p:first-line { text-decoration: none; }
    p.line:first-line { text-decoration: underline; }

    -->
    </style>

    <body>

    <p class="normal"> First character of this paragraph will 
    be normal and will have font size 40 px;</p>

    <p class="line">The first character of this paragraph will be 3em big
    and in red color as defined in the CSS rule above. Rest of the
    characters in this paragraph will remain normal. This example 
    shows how to use :first-letter pseudo element to give effect to
    the first characters of any HTML element.</p>

    </body>
</html>

练习CSS:第一个字母伪元素

本段的第一个字符 是正常的,字体大小为40px

本段的第一个字符将是3em大 和上面CSS规则中定义的红色。其余的 本段中的字符将保持正常。这个例子 演示如何使用:要生效的第一个字母伪元素 任何HTML元素的第一个字符

我可以同时使用“p”标记上的第一个字母和第一行这两个伪元素吗

<p class="normal"  "line"> First character of this paragraph will 
be normal and will have font size 40 px;</p> 

<p >The first character of this paragraph will be 3em big
and in red color as defined in the CSS rule above. Rest of the
characters in this paragraph will remain normal. This example 
shows how to use :first-letter pseudo element to give effect to
the first characters of any HTML element.</p>
本段的第一个字符 是正常的,字体大小为40px

这一段的第一个字符是3em大 和上面CSS规则中定义的红色。其余的 本段中的字符将保持正常。这个例子 演示如何使用:要生效的第一个字母伪元素 任何HTML元素的第一个字符

如果您想在CSS中使用类“链接”,则必须将类名空格用引号分隔:

<p class="normal line">Blah 42</p>
我建议你这样做。拥有一堆css类将使您的标记真正不可读。如果您想在某个段落中使用此功能,您应该查看是否可以向父元素添加特定的CSS定义:

p#myEmphasedParagraph:first-line {blah...}
p#myEmphasedParagraph:first-letter {blah...}
在html中,则如下所示:

<p id="myEmphasedParagraph">blah</p>
废话


就像@wog说的,你需要加入像
class=“normalline”
这样的类。这里有一个jsfiddle来说明是的,您可以

非常感谢:感谢您的帮助很棒:)如果有帮助,请将答案标记为正确答案,谢谢Peteroak,再次感谢您推荐这个网站。我个人觉得这对我非常有用。:)我也喜欢它。它非常适合测试新事物
<p id="myEmphasedParagraph">blah</p>