在CSS中为div使用多个ID [英] Use multiple IDs for divs in CSS

查看:361
本文介绍了在CSS中为div使用多个ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站和CSS上有3个DIV元素:

I have 3 DIV Elements on a website and this CSS:

#box-left, #box-middle, #box-right a {
    text-decoration:none;
    color:#000000;
}

它似乎只在 #box上工作-right 元素。

有什么想法吗?

推荐答案

您必须放入

#box-left a, #box-middle a, #box-right a {
    text-decoration:none;
    color:#000000;
}

逗号分隔符列表上的每个值都是一个选择器,它是不与下一个元素组合:

Each value on the comma separator list is a selector on its own, it is not combined with the next elements:

#foo, .class p, #bar p:first-child a {
  something;
}

等同于

#foo {
  something;
}

.class p {
  something;
}

#bar p:first-child a {
  something;
}

这篇关于在CSS中为div使用多个ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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