我创建了一个 Ionic 3
侧边菜单
项目。现在我需要将渐变背景颜色设置为整个侧边菜单。这似乎是一项直截了当的任务。但它并没有起作用。有什么建议吗?
app.html
<ion-menu [content]="content">
<ion-content class="background-gradient">
<ion-list no-lines>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)" class="border-none" outline>
<ion-icon [name]="p.icon" item-left></ion-icon> {{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
app.component.ts
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = HomePage;
pages: Array<{ title: string, component: any, icon: string }>;
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
this.initializeApp();
// used for an example of ngFor and navigation
this.pages = [
{ title: 'Home', component: HomePage, icon: 'game-controller-b' },
{ title: 'Activity', component: '', icon: 'browsers' },
{ title: 'Contacts', component: '', icon: 'play' },
{ title: 'Add Project', component: '', icon: 'settings' },
{ title: 'Settings', component: '', icon: 'settings' }
];
}
app.scss
.background-gradient {
background: -webkit-linear-gradient(-55deg, #50a2a7 35%, #e9b44c 100%);
}
.border-none {
border: none;
}
现在看起来像这样:
Q: 你能告诉我如何将 渐变背景颜色
添加到 菜单项
吗?例如整个 侧边菜单
。我已经尝试了许多方法,但还没有成功:(