I want to implement a floating menu in an Ionic 2 project

Image floating menu

So far I have implemented ie (ion-fab) buttons, but button labels can only be placed on top or bottom of buttons. I want to place them on the left side of the button. Image attached for clarification.

+4
source share
2 answers

HTML CODE

<ion-content>
    <div id="ListBackdrop" *ngIf="fabButtonOpened==true" ></div> 
</ion-content> 
<ion-fab right bottom #fab>
   <button ion-fab (click)="openFabButton()">
       <ion-icon name="add"></ion-icon>
    </button>
   <ion-fab-list side="top">
     <button ion-fab>
         <img src="assets/friend_add.png"> 
     </button>
     <ion-label class="fablabelfriend">Friend</ion-label>
     <button ion-fab>
             <img src="assets/family_add.png">
     </button>
     <ion-label class="fablabelfamily">Family</ion-label>
   </ion-fab-list>
 </ion-fab>

Css file

   .fablabelfamily
            {
              position: absolute;
              width: 100%;
              padding-right: 220px;
              padding-bottom: 75px;
              margin-top: 0px;
              margin-bottom: 0px;
              font-weight: bold;
            }
.fablabelfriend{
             position: absolute;
             width: 100%;
             padding-right: 220px;
             padding-bottom: 30px;
             margin-top: 10px;
             margin-bottom: 0px;
             font-weight: bold;
          }
#ListBackdrop{
         background-color: white !important;
         position: fixed !important;
         height: 100%;
         width: 100%;
         z-index: 1;
         opacity: 0.8
      }

TypeScript File

 export class myClass{
     fabButtonOpened: Boolean;
      constructor(public navCtrl: NavController, private global: globalVariable, private http: Http, public platform: Platform) {
         this.fabButtonOpened=false;

//All other functions inside constructor 
    }

        openFabButton(){
          if(this.fabButtonOpened==false){
              this.fabButtonOpened=true;
          }else{
              this.fabButtonOpened=false;
          }
        }
    }
+4
source

Anu's answer worked for me, but the shortcuts prevented me from clicking on my buttons. I made the following fix to fix this. The overlays overlap from above, as the position of the marks is fixed.

 <ion-fab-list side="top">
   <ion-label class="fablabelfriend">Friend</ion-label>
  <ion-label class="fablabelfamily">Family</ion-label>      
  <button ion-fab>
     <img src="assets/friend_add.png"> 
  </button>
  <button ion-fab>
      <img src="assets/family_add.png">
  </button>

   </ion-fab-list>
 </ion-fab>
0
source

Source: https://habr.com/ru/post/1673462/


All Articles