首页  >  问答  >  正文

为什么我不能从 html 代码中调用我的 css 超链接样式类?

我想为超链接样式创建多个类。

我想要一个默认类以及一个用于导航菜单的特殊类。

这是我的 CSS 代码:

a {
    color: white;
    text-decoration: none;
}

.menu-items a {
    color: black;
    text-decoration: none;
}

我尝试在 html 中调用“menu-items”类,但它继续使用上面显示的默认 a{} 样式。

这是 html 代码:

<div class="container-outside">
    <div class="container-inside">
        <ul class="ul-list">
            <li>
                <a class="menu-items" href="temperature.html">Temperature</a></li>
            <li>|</li>
            <li>Weight</li>
            <li>|</li>
            <li>Currency</li>
        </ul>
    </div>
</div>

我尝试删除默认类并创建两个特殊类,但没有成功。这里有点不知所措。

P粉068486220P粉068486220169 天前301

全部回复(2)我来回复

  • P粉006977956

    P粉0069779562024-04-05 10:31:31

    可以直接把类名.menu-items

    CSS a { color: white; text-decoration: none; } .menu-items { color: black; text-decoration: none; }

    回复
    0
  • P粉563446579

    P粉5634465792024-04-05 00:58:02

    您的选择器不正确,因为 menu-items 不是 as 父级。您应该像这样选择标签:

    a.menu-items {
    color: black;
    text-decoration: none;}

    回复
    0
  • 取消回复