我有以下的HTMLCSS继承不父类的属性
<div id="borderContainer" class="scViewer" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline',gutters:false">
<div id="buttonPagerContentPane" data-dojo-type="dijit/layout/ContentPane" align="center" data-dojo-props="region:'bottom'" class="buttonContentPane">
<div id="buttonPagerTitle" class="ContentPaneTitle">
Sheet Selector <br>
</div>
<button data-dojo-type="dijit/form/Button" type="button" data-dojo-attach-point="PreviousButtonAttachNode" id="previousButton" class="scViewButtonContent buttonContentPane">
Previous
</button>
<button data-dojo-type="dijit/form/Button" type="button" data-dojo-attach-point="NextButtonAttachNode" id="nextButton" class="scViewButtonContent">
Next
</button>
</div>
</div>
下面CSS:
.scViewer {
color: #2546ff;
}
.scViewer .buttonContentPane {
padding: 5px 5px;
color:#FFFFFF;
border-radius: 5px;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
}
.scViewer .ContentPaneTitle{
color: #2546ff;
font-weight: bold;
}
.scViewer .buttonContentPane .scViewButtonContent{
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
text-decoration: none;
}
我的问题是,这两个一个/下一个按钮不继承buttonContentPane类没有明确定义它,即使它在父代buttonPagerTitle <div>
之内。为了演示上述内容,我明确定义了不带buttonContentPane属性的nextButton,开发工具中生成的HTML不包含定义的buttonContentPane,但是遗传部分包含buttonContentPane,其属性变灰:
我的总体目标是在我的组织中重新使用样板CSS代码。我的语法错了吗?我不正确地构造选择器吗?感谢您的时间
是他们下一个类= “scViewer” 的地方?由于您只发布了其他代码的图片,因此我们无法“按Ctrl-f”查找它们是否存在。一般提示:代码图片绝对没用。 –
@MarcB是的,它被声明为根div,我原本排除它,但它在那里(见编辑)。图片只是为了说明该类在开发工具中确实没有定义。 – Rice
据我所知,在CSS属性不被子元素继承。因此.scViewer .buttonContentPane只会影响类.buttonContentPane的元素。使用.scViewer .buttonContentPane .scViewButtonContent明确定义按钮是一个选项,可以根据需要为其指定样式,也可以使用逗号尝试.scViewer .buttonContentPane,.scViewer .buttonContentPane按钮,因此不必编写相同的代码两次。编辑:只有特定的CSS样式可以由父类(字体家族,文本对齐等)的孩子继承 – Benneb10