https://jsbin.com/jarepefixe/edit?html,js,output
Here is what I came up with. Its essence is a function that looks at which tab you are using and will only display other tabs if they are on the same tab of the current tab. The exception is on the endpoints to show either the next two tabs in front (located at index 0) or the previous two tabs (located at index 6 (for this example)). This will support 3 tabs at once. I hide tabs by applying a CSS class to elements to set their display to "none".
It should be noted that my proposed solution is not trying to get rid of the βdotsβ (I forgot the name of this) below. The reason for this is that the user interface design would be poor so as not to show the true number of tabs available to the user at any given time.
In fact, I would even go so far as to recommend against trying to make the tabs not visible at all (Android had sliding tabs in its menu system, but they got rid of them due to poor UX - people weren can't say that they were slippery ) On Android, TabHost is deprecated since the UX people decided that the tabs really werenβt very suitable for mobile devices because of the exact problem you were having. If possible, I would consider different ways to interact with your application. Perhaps a hamburger menu with various tab options? Of course, it depends on your needs. maybe just completely separate the tabs and save / only / dots at the bottom to tell the user that they have more screens to scroll through (e.g. Snapchat does this).
Returning to your question, I doubt that there is a βpurelyβ HTML solution for showing / not displaying tabs, since HTML is just the content of the page, not the visual (CSS) or behavior (JS) of the page. However, you can work with CSS selectors with pseudo-selectors, but in the end, this can lead to a lot of hard-coded rules (using identifiers, etc.) if you want a solution that avoids JS.
Here are the changes to your code that I made:
angular.module('ionicApp', ['ionic']) .controller('MyCtrl', function($scope,$ionicSlideBoxDelegate) { $scope.slideIndex = 0;
body { cursor: url('https://ionicframework.com/img/finger.png'), auto; } .slide-tab{ display: table; overflow: hidden; margin: 0; width: 100%; background-color: #eff0f2; border-bottom: 2px solid #00897B; } .slide-tab li{ float: left; line-height: 38px; overflow: hidden; padding: 0; } .slide-tab a{ background-color: #eee0f2; border-bottom: 1px solid #fff; color: #e81; font-weight: 500; display: block; letter-spacing: 0; outline: none; padding: 0 20px; text-decoration: none; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; border-bottom: 2px solid #00897B; } .current a{ color: #efe; background: #00897B; } .hidden a { display:none; }
<html ng-app="ionicApp"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>Ionic Slide Tab</title> <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"> <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script> </head> <body ng-controller="MyCtrl"> <ion-content> <div class="row"> <ul class="slide-tab"> <li ng-class="determine_class(0)"><a href="#" ng-click="activeSlide(0)">Tab01</a></li> <li ng-class="determine_class(1)"><a href="#" ng-click="activeSlide(1)">Tab02</a></li> <li ng-class="determine_class(2)"><a href="#" ng-click="activeSlide(2)">Tab03</a></li> <li ng-class="determine_class(3)"><a href="#" ng-click="activeSlide(3)">Tab04</a></li> <li ng-class="determine_class(4)"><a href="#" ng-click="activeSlide(4)">Tab05</a></li> <li ng-class="determine_class(5)"><a href="#" ng-click="activeSlide(5)">Tab06</a></li> <li ng-class="determine_class(6)"><a href="#" ng-click="activeSlide(6)">Tab07</a></li> </ul> </div> <ion-slide-box on-slide-changed="slideChanged(index)" active-slide="slideIndex" class="padding"> <ion-slide> <h3>Tab 1</h3> <p>Page 1</p> </ion-slide> <ion-slide> <h3>Tab 2</h3> <p>Page 2</p> </ion-slide> <ion-slide> <h3>Tab 3</h3> <p>Page 3</p> </ion-slide> <ion-slide> <h3>Tab 4</h3> <p>page 4</p> </ion-slide> <ion-slide> <h3>Tab 5</h3> <p>page 5</p> </ion-slide> <ion-slide> <h3>Tab 6</h3> <p>page 6</p> </ion-slide> <ion-slide> <h3>Tab 7</h3> <p>page 7</p> </ion-slide> </ion-slide-box> </ion-content> </body> </html>
masquarainian
source share