I want to add a custom CSS Class to a dijit/layout/ContentPane so I'm able to style it myself.
This is cause I got more than one tab in my TabContainer where my ContentPanes are located and I don't want to double the borders. Using a border all around the Tab will double the border so I removed the left border of the tabs. In the first tab in the TabContainer I need the left border, too.
To get this I tried to assume the first ContentPane a custom CSS class which will do it.
As you see me writing here, I didn't find a way to do this.
I tried it within the data-dojo-props with
<div data-dojo-type="dijit/layout/ContentPane" title="FunnyTitle" data-dojo-props="class:'firstTab'">
So this didn't work. I tried to add it like I do it in a simple HTML element with class="firstTab"
<div data-dojo-type="dijit/layout/ContentPane" title="FunnyTitle" class="firstTab">
Both ways didn't add my class to the ContentPane.
So how is it done?
The
classproperty is actually not used for that kind of purpose, but it used for identifying of which type the widget is.However, the
classattribute should work, because declarative widgets usually keep their parent attributes. If I have the following HTML:It eventually gets rendered into:
However, please note that when using a
dijit/layout/ContentPaneinside adijit/layout/TabContainera lot of additional CSS is added, possibily overriding your own CSS.For example, for overriding the background color of a tab inside a
dijit/layout/TabContainer, I had to use the following CSS selector:Demo: http://jsfiddle.net/Lcog9saj/
But also, be aware that the borders generated by the
TabContainerare not applied to theContentPaneitself, but to an element with classname.dijitTabContainerTop-container(part of theTabContaineritself).If this really doesn't work, then you can always access the
domNodeproperty of the widget you're trying to alter, for example: