Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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
Html 第一个孩子不在我的代码中工作_Html_Css - Fatal编程技术网

Html 第一个孩子不在我的代码中工作

Html 第一个孩子不在我的代码中工作,html,css,Html,Css,我不知道为什么我的第一个孩子不工作。这是我的html: <!DOCTYPE html> <link href='http://fonts.googleapis.com/css?family=Geo' rel='stylesheet'> <title>Mira's place</title> <header> <a href="index.html">Mira's place</a><br>

我不知道为什么我的第一个孩子不工作。这是我的html:

<!DOCTYPE html>
<link href='http://fonts.googleapis.com/css?family=Geo' rel='stylesheet'>
<title>Mira's place</title>
<header>
    <a href="index.html">Mira's place</a><br>
    <h2>&#8220;<span id="quote">If nothing, then this.</span>&#8221;</h2>
        <ul>
            <li><a href="#">Home</a>
            <li><a href="#">Games</a>
            <li><a href="#">Pixel Art</a>
            <li><a href="#">Contact</a>
        </ul>
</header>
<section>
    <h2>This is test H2</h2>
    <p>This is lorem ipsum shitsum, blah <a href="#">Test</a> blah baldflksafdjsl adslkf ajfdlks ajfldsa jflksda lfhsdalf jdsalfh sdlfdshfdsk fjsdl ajfl
</section>
<footer>
    <p>(C) MiraCZ 2013 - You can copy anything here! 
</footer>
我只想让第一个
a
的大小为36px。有人能帮忙吗?为什么它会影响其他
a
s?这是我的名片

这是我看到的。我添加了红色箭头以显示我不希望的
a
s大小等等

导航中的所有
标记都是包含
  • 标记的第一个子项,因此与规则匹配

    文本区域中的元素是包含
    的元素的第一个子元素,因此与规则匹配


    在你实际想要影响的元素上使用ID或类名要容易得多。

    看起来像你只想要第一个<代码>

    我想你应该考虑使用<代码>:nth-of -类型()/<代码>选择器。它似乎更适合此应用程序

    first child
    只选择第一个孩子是什么。使用
    nth类型
    可以保证选择头元素的第一个直接锚点子元素

    header > a:nth-of-type(1) {
    color: #FF628C;
    font-size: 36px;
    }
    
    .

    .

    使您工作的不是类型的第n个
    n,而是子选择器
    。见@RichardJPLeGuen我知道
    /* only target an <a> element which is the first immediate child of a <header> element */
    header > a:first-child {
        /* ... */
    }
    
    header > a:nth-of-type(1) {
    color: #FF628C;
    font-size: 36px;
    }