我有一个动态HTML结构,并且我只想在存在包含一个特定类的元素时应用CSS规则。当存在一个具有特定类的子元素时应用CSS
<div class="inline-container">
<div class="form-element>
<label class="paragraph">Some text</label>
<div class="select-wrapper">
<select>
<option value="1">1</option>
</select>
</div>
</div>
<input type="hidden">
<input type="hidden">
</div>
当输入类型被启用时,它们的结构变成与“form-element”相同的结构,当然也具有相同的类。我只想在代码中启用一个样式时应用样式。我想应用的样式适用于标签和选择。我已经尝试过使用独特的孩子或只有类型,但不适用于这种情况。
label:only-child {
padding: 0% 29% 0% 0% !important;
}
div:only-child {
select {
padding: 0% 10% 0% 59% !important;
}
}
的HTML不能修改只有CSS(.LESS文件)
你能显示示例标记,你想选择申请? – Danield
相关 - 我认为 - https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector –
也 - https://stackoverflow.com/questions/5545649/can-i-combine- n-child-or-any-type-with-an-any-selector –