以下示例
我有一个带有字段集和按钮的表单。按钮和字段集都有边框。我希望边框仅用于fieldset。怎么样?
(我的示例中的CSS删除了两个边框 - 对于fieldset和按钮,当我希望按钮保持未定位时)
<Target Name="UpdatePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(UpdateCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
<Exec Command="$(UpdateCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>
<!-- Commands -->
<UpdateCommand>$(NuGetCommand) update "$(PackagesConfig)" -source "$(PackageSources)" -id AutoUpdater $(NonInteractiveSwitch)</UpdateCommand>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
UpdatePackages;
$(BuildDependsOn);
</BuildDependsOn>
#select_spec_form #submit_button {
border: 0;
}
答案 0 :(得分:1)
只需将选择器更改为仅选择字段集#select_spec_form fieldset
。也不要使用具有两个不同元素的相同ID。
/* Remove the ID from selector if you want to select all the fieldset in the same page and container */
#select_spec_form fieldset#another_ID {
border: 0;
}
<form id="select_spec_form">
<fieldset id="another_ID">
<input name="submit[submit]" id="submit_button" value="View" type="submit">
</fieldset>
</form>
答案 1 :(得分:1)
首先要做的事情是:你不能对多个元素使用相同的id。如果您需要为css执行此操作,请改用class属性。
说到CSS,你必须分别引用每个对象,即使它们都共享父#select_spec_form。
#select_spec_form fieldset{
border:1px solid red;
}
#select_spec_form input{
border:1px solid black;
}
<form id="select_spec_form">
<fieldset>
<input name="submit[submit]" id="submit_button" value="View" type="submit">
</fieldset>
</form>