简体   繁体   English

CSS选择器不适用于div中的元素

[英]CSS Selector not working on elements within a div

I have the following HTML structure: 我有以下HTML结构:

<div class="formFields">
     <label> Field 1: </label>
     <input type="text" value="" name="field1" />
</div>

And my CSS selectors are as follows: 我的CSS选择器如下:

#formFields {clear:both;}
#formFields label {font-weight:bold;}

The clear:both; clear:both; is being applied to the div, but the font-weight:bold; 应用于div,但font-weight:bold; is not being applied to the labels. 未应用于标签。 How would I apply this font-weight to the labels? 我如何将这种font-weight应用于标签?

At the moment, none of the rules is being applied to the div. 目前,没有规则适用于div。

  • # is the ID selector #是ID选择器

  • . would be the class selector 将是类选择器

so you'll either have to give the rules the class selector 所以您要么必须给规则提供类选择器

.formFields

or give the div the ID formFields : 或为div提供ID formFields

<div id="formFields">

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

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