CSS多级课程选择

时间:2017-01-19 18:08:53

标签: html css

所以我的问题是如何仅通过ID class="wp"将样式应用于#test? 因为在我的主项目中我有很多类,如wp,但上面的id与那些类不同,那么如何使用id leaveit中的类不会被更改?



#test {
  text-align: center;
  color: red;
  width: 550px;
  background: black;
  height: 250px;
}

<div id="test">
  <div class="blablabla">
    <p class="wp">test</p>
    <p class="leaveit">This paragraph will be red and</p>
  </div>
</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

#test .wp { /*styles go here*/ }
很容易。

答案 1 :(得分:0)

使用 { List<Instituition> Instituitions = new List<Instituition>() { new Instituition { Name = "Name1", Alias = "",Area="" }, new Instituition { Name = "Name1", Alias = "Alias1",Area="" }, new Instituition { Name = "name2", Alias = "Audi" ,Area="444"}, new Instituition { Name = "Name1", Alias = "",Area="Garden" }}; var results = Instituitions.GroupBy(i => i.Name, i => i.Alias, (key, g) => new { Name = key, Alias = g.Where(a =>a != "").FirstOrDefault(), Area = Instituitions.Where(a=>a.Name == key && a.Area != "").Select(a=>a.Area).FirstOrDefault() } ); } class Instituition { internal string Name; internal string Alias; internal string Area; } 定位具有#test ID的元素test  在.wp元素中使用wp类定位元素。

请注意,使用#test来定位CSS中的元素被认为是一种不好的做法,因为很难覆盖它。

id