简体   繁体   English

CSS组合属性选择器

[英]CSS combined attribute selector

I'm working on a class in which I need to translate a PSD to HTML/CSS, and I've been trying to select something but I'm not even sure it's possible, I want to select the links in a div with the id="topbar" . 我正在上一个需要将PSD转换为HTML / CSS的类,并且我一直在尝试选择某些内容,但我甚至不确定是否有可能,我想在div中选择带有id="topbar"

Here is what I tried: 这是我尝试过的:

div[id="topbar"] p{
    text-decoration: none;
    font-color:white;
}

It doesn't seem to work, but is it because this is impossible or am I just missing something? 它似乎不起作用,但这是因为这是不可能的,还是我只是想念一些东西?

this is what the HTML part should look like: 这是HTML部分的外观:

    <div id="topbar">
        <p><a>Agent Login</a></p>
        <p><a>Customer Login</a></p>
        <p>Not a member ? <a class="colorlink">Register</a></p> 
        <p>Call us now: 815-123-4567</p>
    </div>

if you need to select the links then your selector should be 如果您需要选择链接,则选择器应为

[id="topbar"] a {
  text-decoration: none;
  color:white;
}

(currently you're selecting all the paragraphs). (当前您正在选择所有段落)。 Also note that: 另请注意:

  • the property font-color doesn't exist: use color instead 属性font-color不存在:使用color代替
  • the selector doesn't need to be overly specific and the element can be omitted 选择器不需要过于具体,可以省略元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM