*ngIf hide some content on mobile screen, Angular 4

后端 未结 9 2150
盖世英雄少女心
盖世英雄少女心 2020-12-13 04:47

I have:

showHide: false;

Content
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 05:18

    Use the below code into the OnInit()

    inMobile:boolean = false
    ngOnInit() {
      if (window.screen.width === 360) {
        this.isMobile = true;
      }
    }
    

    by using above code we can put two css; based on desktop and mobile:-

    
    

    or

    
    

    CSS:

    .button{
    margin-left:100px;
    }
    .button-mobile{
    margin-left:50px;
    }
    

提交回复
热议问题