Search code examples
htmlcordovamaterial-design-lite

MDL in Cordova for Visual Studio


I am trying to make an app for school. I am using Cordova within VS. For the UI I would like to use MDL (Material Design Lite). Although I have one issue... I can't get the navigation menu to open. I have tried multiple ways of getting this to work (without the in the parent ). Either the menu icon doesn't show up, or when it does, it doesn't open the menu when clicked. I have included the index.html and index.css contents below, feel free to take a look at them in order to help me make this work. Thanks.

* {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

body {
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: none;
    -webkit-user-select: none;
	background-color:#E4E4E4;
    background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
    background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
    background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
    background-image:-webkit-gradient(
        linear,
        left top,
        left bottom,
        color-stop(0, #A7A7A7),
        color-stop(0.51, #E4E4E4)
    );
    background-attachment:fixed;
    font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
    font-size:12px;
    height:100%;
    margin:0px;
    padding:0px;
    text-transform:uppercase;
    width:100%;
	
    background-color:#32383d;
    font-family: 'RobotoRegular', 'Droid Sans', 'Segoe UI', Segoe, 'San Francisco', 'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif;
    font-size:12px;
}

.app {
    background: url(../images/cordova.png) no-repeat center top; 
    position: absolute;             
    left: 50%;
    top: 50%;
    height: 50px;                  
    width: 225px;                   
    text-align: center;
    padding: 180px 0px 0px 0px;     
    margin: -115px 0px 0px -112px;
}

@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
    .app {
        background-position:left center;
        padding:75px 0px 75px 170px;
        margin:-90px 0px 0px -198px;
    }
}

h1 {
    font-size:24px;
    font-weight:normal;
    margin:0px;
    overflow:visible;
    padding:0px;
    text-align:center;
}

.event {
    border-radius:4px;
    -webkit-border-radius:4px;
    color:#FFFFFF;
    font-size:12px;
    margin:0px 30px;
    padding:2px 0px;
}

.event.listening {
    background-color:#333333;
    display:block;
}

.event.received {
    background-color:#4B946A;
    display:none;
}

@keyframes fade {
    from { opacity: 1.0; }
    50% { opacity: 0.4; }
    to { opacity: 1.0; }
}
 
@-webkit-keyframes fade {
    from { opacity: 1.0; }
    50% { opacity: 0.4; }
    to { opacity: 1.0; }
}
 
.blink {
    animation:fade 3000ms infinite;
    -webkit-animation:fade 3000ms infinite;
}
<!DOCTYPE html>
<html>
    <head>
    
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css" />
        <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
        <script type="stylesheet" src="https://code.getmdl.io/1.3.0/material.min.js"></script>
        <title>PHSRadio</title>
    </head>
    <body>
        <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
            <header class="mdl-layout__header">
                <div class="mdl-layout__drawer-button"><i class="material-icons">menu</i></div>
                <div class="mdl-layout__header-row">
                    <span class="mdl-layout-title">PHS Radio</span>
                    <div class="mdl-layout-spacer"></div>
                </div>
            </header>

        <div class="mdl-layout__drawer">
            <span class="mdl-layout-title">PHS Radio</span>
                <nav class="mdl-navigation">
                    <a class="mdl-navigation__link" href="">Home</a>
                    <a class="mdl-navigation__link" href="">Requests</a>
                    <a class="mdl-navigation__link" href="">Settings</a>
                    <a class="mdl-navigation__link" href="">About</a>
                </nav>
        </div>
            <main class="mdl-layout__content">
                <!--Page Content-->
            </main>
        </div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="scripts/platformOverrides.js"></script>
        <script type="text/javascript" src="scripts/index.js"></script>
        <script type="text/javascript" src="scripts/jquery-3.1.1.js"></script>
        <script type="text/javascript" src="scripts/jquery-3.1.1.min.js"></script>
        <script type="stylesheet" src="https://code.getmdl.io/1.3.0/material.min.js"></script>
    </body>
</html>


Solution

  • your error is in this line

    <script type="stylesheet" src="https://code.getmdl.io/1.3.0/material.min.js"></script>
    

    Change it to

    <script type="text/javascript" src="https://code.getmdl.io/1.3.0/material.min.js"></script>
    

    and it will work.