ionic2 - 我想在 Ionic 2 项目中实现 float 菜单

标签 ionic2 floating-action-button

Image with Floating menu

到目前为止,我已经实现了按钮,即 (ion-fab) 但按钮标签只能放在按钮的顶部或底部。我想将它们放在按钮的左侧。附上图片以进行更多说明。

最佳答案

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;
          }
        }
    }

关于ionic2 - 我想在 Ionic 2 项目中实现 float 菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43085973/

相关文章:

android - 如何更改扩展 float 操作按钮的形状?

angular - 从主组件捕获模态 Controller 中的解雇事件

Android 如何从 Material Design 文档中实现 Bottom Sheet

android - 滚动时在 NestedScrollView 中隐藏 FAB

android - 使用 AnimationUtils 显示和隐藏 FAB 时的竞争条件

android - 单击时切换 FloatingActionButton 图标

javascript - 如何使用 ionic 2(cordova) 像画廊或任何媒体播放器一样列出本地视频文件

ajax - angular2 使用 HTTP 发布 XML 类型请求数据

ionic-framework - ViewChild 对我不起作用 - 升级到 beta7

css - 使用内联 CSS 设计组件样式 - Ionic2、AngularJS