Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add background image to ionic side menu

I have an ionic side menu. I want to add background-image. Side-Menu codes are the following.

<ion-side-menus enable-menu-with-back-views="true">
<ion-side-menu-content>
    <ion-nav-bar class="bar-dark">
        <ion-nav-back-button>
        </ion-nav-back-button>      
        <ion-nav-buttons side="left">
            <button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
        </ion-nav-buttons>
        <ion-nav-buttons side="right">
            <button  class="button button-icon button-clear ion-log-out" ng-click="logout()"></button>
        </ion-nav-buttons>          
    </ion-nav-bar>
    <ion-nav-view name="menuContent" style="background-color:red;">   
    </ion-nav-view>
</ion-side-menu-content>
    <ion-side-menu side="left">
        <ion-header-bar class="bar-dark">
            <h1 class="title">Menu</h1>
        </ion-header-bar>
        <ion-content>
            <ion-list>
                <ion-item menu-close href="#/app/dashboard">
                    <i class="icon icon-dashboard" style="font-size:20px;margin-right:10px;"></i>
                    Dashboard
                </ion-item> 
<ion-item menu-close href="#/app/dashboard">
                    <i class="icon icon-dashboard" style="font-size:20px;margin-right:10px;"></i>
                    Statistics
                </ion-item>             
            </ion-list>
        </ion-content>
    </ion-side-menu>
</ion-side-menus>

How to add background image to ionic side menu?

like image 624
Yasemin çidem Avatar asked Feb 24 '16 07:02

Yasemin çidem


1 Answers

You can define your custom CSS as follows:

.my-container {
    background-image:  url("http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg");
    background-repeat: repeat;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
    height: 100%;
    position: absolute;
}
.transp .item-content {
    background-color: transparent !important;
    color: #fff;
}

and apply those classes to proper HTML items:

<ion-side-menu side="left">
    <ion-header-bar class="bar-dark">
        <h1 class="title">Menu</h1>
    </ion-header-bar>
    <ion-content class="my-container">
        <ion-list>
            <ion-item class="transp" menu-close href="#/app/dashboard">
                <i class="icon icon-dashboard" style="font-size:20px;margin-right:10px;"></i>Dashboard
            </ion-item> 
            <ion-item class="transp" menu-close href="#/app/dashboard">
                <i class="icon icon-dashboard" style="font-size:20px;margin-right:10px;"></i>Statistics
            </ion-item>             
        </ion-list>
    </ion-content>
</ion-side-menu>

Here is a codepen: http://codepen.io/beaver71/pen/WrqgNm

like image 134
beaver Avatar answered Nov 01 '22 02:11

beaver