Home browser like tab using md-tab (css)
Reply: 1

browser like tab using md-tab (css)

Shashank Patil
1#
Shashank Patil Published in 2018-01-13 06:00:37Z

I am looking for css of browser like tab using md-tab. Please find attached screenshot for your ref. Overriding material tab css is complete headache.

Bhuwan Bhatt
2#
Bhuwan Bhatt Reply to 2018-01-13 06:45:54Z

I tried your GitHub code using bootstrap nav-tabs. Try to use active:after to overlap the border issue

Stack Snippet

(function() {
  angular.module('tabDemo', [])

    .controller('tabCtrl', ['$scope', function($scope) {
      /** holds tabs, we will perform repeat on this **/
      $scope.tabs = [{
        id: 1,
        content: 'This is a default tab on load'
      }]

      $scope.counter = 1;
      /** Function to add a new tab **/
      $scope.addTab = function() {
        $scope.counter++;
        $scope.tabs.push({
          id: $scope.counter,
          content: 'Any Content'
        });
        $scope.selectedTab = $scope.tabs.length - 1; //set the newly added tab active. 
      }

      /** Function to delete a tab **/
      $scope.deleteTab = function(index) {
        $scope.tabs.splice(index, 1); //remove the object from the array based on index
      }

      $scope.selectedTab = 0; //set selected tab to the 1st by default.

      /** Function to set selectedTab **/
      $scope.selectTab = function(index) {
        $scope.selectedTab = index;
      }
    }])
})()
.nav-tabs {
  margin-top: 10px;
  white-space: nowrap;
  width: 100%;
  overflow: auto;
  padding-top: 10px;
}

.nav.nav-tabs>li {
  float: none;
  margin-bottom: -1px;
  display: inline-block;
}

.nav-tabs>li>a {
  cursor: pointer;
  margin: 0;
  border: 1px solid #ccc;
  background: #eee;
  margin-left: -1px;
}

.nav-tabs li a span:hover {
  color: red;
  cursor: pointer;
}

.nav-tabs>li.active>a {
  z-index: 1;
}

.nav-tabs>li.active>a:after {
  content: "";
  position: absolute;
  top: -10px;
  left: -5px;
  bottom: -1px;
  right: -5px;
  background: white;
  z-index: -1;
  border: 1px solid #ddd;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<body ng-app="tabDemo">
  <div role="tabpanel" ng-controller="tabCtrl">
    <ul class="nav nav-tabs" role="tablist">
      <li role="presentation" ng-repeat="tab in tabs" ng-click="selectTab($index)" ng-class="{'active':selectedTab == $index}">
        <a data-target="#tab" aria-controls="home" role="tab" data-toggle="tab">Tab {{tab.id}} <span ng-click="deleteTab($index)" class="glyphicon glyphicon-remove"></span></a>
      </li>
      <li role="presentation" ng-click="addTab()">
        <a aria-controls="home" role="tab" data-toggle="tab">( + )</a>
      </li>
    </ul>
    <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="tab">
        <h1>Tab {{tabs[selectedTab].id}}</h1>
        <h3>Content:- {{tabs[selectedTab].content}}</h3>
      </div>
    </div>
  </div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-animate.min.js"></script>
</body>

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311855 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO