开发者

CSS Class by element ID?

开发者 https://www.devze.com 2023-01-10 19:47 出处:网络
I have a following css #container { border:1px solid black; } #container #header { color:blue; } #container #footer

I have a following css

#container
{
        border:1px solid black;
}
#container #header
{
    color:blue;
}

#container #footer
{
    color:red;
}

Can i write it as

#container
{
        border:1px solid black;
        #header
        {
            color:blue开发者_开发问答;
        }

        #footer
        {
            color:red;
        }
}

So the #header and #footer are still select as #container's childs element. Or i need to use some css framework like .LESS ?


Nope, CSS doesn't support that. I agree, it would be useful. However, you're right, it looks like LESS supports it.


Yes only if you use SASS, not possible in vanilla CSS.


CSS doesn't support that syntax out of the box, so yes you would have to use .LESS

0

精彩评论

暂无评论...
验证码 换一张
取 消