CSS语法,用于选择由其id标识的元素的类

时间:2012-02-20 23:46:44

标签: css

对于此代码

<div id="dogs" class="content">hello</div>
<div id="frogs" class="content">hello</div>
<div id="hogs" class="content">hello</div>
<div id="logs" class="content">hello</div>

如何从具有id狗的元素中选择类content

1 个答案:

答案 0 :(得分:2)

你可以试试这个:

.content#dogs {
  font: bold 28px sans-serif;
  color: #800000;
}
<div id="dogs" class="content">hello</div>
<div id="frogs" class="content">hello</div>
<div id="hogs" class="content">hello</div>
<div id="logs" class="content">hello</div>