AngularJS Material Design : Different colors for different tabs in md-tabs

青春壹個敷衍的年華 提交于 2019-12-22 08:18:32

问题


Is there a way to set different background colors for different tabs in md-tabs ? The default is no color as can be seen in tabs demo

I tried <md-tabs background-color="green"> but it's not working


回答1:


AngularJS Material design (md) tabs, md-tabs background color is transparent and uses the background color of your main container. Try to add CSS class for md-tabs .

Added background to entire md-tabs

md-tabs {
    background: red;
    border: 1px solid #e1e1e1; }

By adding CSS childs to md-tab class, you can see different colors for different tabs.

 .md-tab:first-child{background: green; } 
 .md-tab:nth-child(2){background: pink; } 
 .md-tab:nth-child(3){background: blue; } 

fiddle https://jsfiddle.net/cxf3otz9/

codepen http://codepen.io/anon/pen/zGNEyw




回答2:


Upon evaluating source code, i came to there a way to achieve dynamic content formatting for tab titles. To get that, please write the code as below

<md-tabs>
    <md-tab>
        <md-tab-label>
            <span ng-class="......">
                Title
            </span>
        </md-tab-label>
        <md-tab-body>
        content
        </md-tab-body>
    </md-tab>
</md-tabs>


来源:https://stackoverflow.com/questions/30542451/angularjs-material-design-different-colors-for-different-tabs-in-md-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!