无法在md-tabs中将md按钮带到前台

时间:2017-02-17 11:01:18

标签: css angularjs angular-material

我正在尝试将md-button添加到md-tabs区域。使用开发人员工具,我可以看到按钮在那里。但它不可见:

Screenshot

我当时认为在css中使用具有非常高值的z-index将解决问题,但它没有:

.superclick {
  right: 0;
  position: absolute;
  z-index: 100;
}

该按钮也不可点击,我不确定原因是它位于后台。

我在这里缺少什么?如何将按钮带到前台?

请参阅我的fiddle或我的代码:

<body>
<script>
angular.module('MyApp', ['ngMaterial'])

.controller('MyCtrl', function ($scope) {
  $scope.statuses = [
      {id: 1, name: "One", description: "First Tooltip"},
      {id: 2, name: "Two", description: "Second Tooltip"},
      {id: 3, name: "Three", description: "Third Tooltip"},
    ];

     $scope.addTab = function(){
      $scope.statuses.push({id: $scope.statuses.length + 1, name: $scope.statuses.length + 1, description: "New Tooltip"});
     }

   $scope.removeTab = function(status){
    alert(status.id);
    var index = $scope.statuses.indexOf(status);
    $scope.statuses.splice(index,1);
   }

});

</script>

<div ng-app="MyApp">
<div ng-controller="MyCtrl">
<md-content class="md-padding">
  <md-tabs class="" md-selected="selectedTab" md-align-tabs="top" md-border-bottom md-autoselect md-dynamic-height>

    <md-tab ng-repeat="status in statuses">
      <md-tab-label>
        {{status.name}}
        <md-tooltip md-direction="bottom">
          {{status.description}}
        </md-tooltip>
      </md-tab-label>
      <md-tab-body>
        <md-button ng-click="removeTab(status)">Remove Tab</md-button>
      </md-tab-body>
    </md-tab>

    <md-button class="superclick">Superclick</md-button>

    <!--<md-tab ng-click="addTab()">
      <md-tab-label> + Add Tab</md-tab-label>
            <md-tab-body>       
      </md-tab-body>
    </md-tab>-->

  </md-tabs>
</md-content>
</div>
</div>
</body>

1 个答案:

答案 0 :(得分:1)

更改opacity&amp; position至(见fiddle)。您的元素被隐藏并与主导航重叠。

md-tab-data {
  opacity:1;
  z-index: 100;
  display: inline-block;
  width:200px;
  float:right;
  position:relative;
}