CSS - 在id中选择类的语法 [英] CSS - Syntax to select a class within an id

查看:99
本文介绍了CSS - 在id中选择类的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过类名在ID中选择标签的选择器语法是什么?例如,为了使内部li变成红色,我需要在下面选择什么?

What is the selector syntax to select a tag within an id via the class name? For example, what do I need to select below in order to make the inner "li" turn red?

<html>
<head>
    <style type="text/css">
        #navigation li
        {
            color: green;
        }

        #navigation li .navigationLevel2
        {
            color: red;
        }
    </style>
</head>
<body>
    <ul id="navigation">
        <li>Level 1 item
            <ul class="navigationLevel2">
                <li>Level 2 item</li>
            </ul>
        </li>
    </ul>
</body>
</html>


推荐答案

#navigation .navigationLevel2 li
{
    color: #f00;
}

这篇关于CSS - 在id中选择类的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆