2017-08-04 55 views
1

我正在向2 div添加一個類以使用[ngClass]切換側邊欄標題如何在放大屏幕時刪除這些類。如何在擴大屏幕的同時刪除ngClass

enter image description here

的問題是加寬屏幕仍然存在,只是因爲類不會被刪除。我如何刪除課程?

在添加類[ngClass]="{'menu-push-onscreen': show}"它會切換,當我加寬屏幕時,它將在那裏本身我應該如何刪除它?

show: boolean = false; 

onToggleHeader(){ 
    this.show=!this.show; 

}

+0

請在您的問題中包含所有相關的代碼。這可以幫助人們理解你所嘗試的以及你可能出錯的地方,從而給出更好的答案。 – yanman1234

+0

@Samson利用mediaQueries的CSS –

+0

請告訴我媒體查詢1024px @RahulSingh –

回答

0

只需設置[ngClass]結合爲空。這裏有一個例子:

在你component.html:

<div [ngClass]="myClass"></div> 

在你的組件類:

... 
// Declare varibale 
myClass:string; 

// Set some variable to true if the screen widening 
if(isScreenWidening){ 
    this.myClass = null; 
} 
... 
0
@media screen and (max-width: 600px) { // this is for screen width less than equal to 600px 

    .yourClass{ 
    // remove all the properties you might have set 
    } 
} 

如果您需要添加更多的媒體查詢按屏幕大小的變化最大或最小寬度。

相關問題