Search code examples
htmlcssfrontendmaterialize

Materialize <div class="col s12 m6 l3"> not working


All references to materialize classes work except for the columns. My HTML webpage is structured as follows:

<head>
    <meta charset="UTF-8">

    <!-- Bootstrap reference -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <!--Import materialize.css-->
    <link type="text/css" rel="stylesheet" href="{% static 'css/materialize.css' %}"  media="screen,projection"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>     
</head>

My stylesheet import works because I use it to customize colors and other parts of my page. When I enter the page I see a section dedicated to the col class to which has sections like .row .col.s3 {...}.

However, the browser does not recognize the columns when I call them like in the Materialize documentation, as such:

<div class="container my-custom-container">
    <div class="row flex">
        <div class="col s12 m6 l3">
            ...
        </div>
     </div>
</div>

It does not get recognized so everything is just 100% container width. My custom CSS for the container and row are:

.flex {
    display: flex;
    flex-wrap: wrap;
}

@media (min-width: 100px) {
    .my-custom-container{
        width:99%;
}}

Could this be the issue? I don't know because I'm not a CSS expert. Can somebody please lend me a hand? Thanks!


Solution

  • <html>
       <head>
          <title>The Materialize Grids Example</title>
          <meta name = "viewport" content = "width = device-width, initial-scale = 1">      
          <link rel = "stylesheet"
             href = "https://fonts.googleapis.com/icon?family=Material+Icons">
          <link rel = "stylesheet"
             href = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
          <script type = "text/javascript"
             src = "https://code.jquery.com/jquery-2.1.1.min.js"></script>           
          <script src = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js">
          </script>             
       </head>
    
       <body>
          <div class = "teal">
             <h2>Mobile First Design Demo</h2>
             <p>Resize the window to see the effect!</p>
          </div>
    
          <hr/> 
          <div class = "row">
             <div class = "col m1 grey center">1</div>
             <div class = "col m1 center">2</div>
             <div class = "col m1 grey center">3</div>
             <div class = "col m1 center">4</div>
             <div class = "col m1 grey center">5</div>
             <div class = "col m1 center">6</div>
             <div class = "col m1 center grey">7</div>
             <div class = "col m1 center">8</div>
             <div class = "col m1 center grey">9</div>
             <div class = "col m1 center">10</div>
             <div class = "col m1 center grey">11</div>
             <div class = "col m1 center">12</div>
          </div>
    
          <div class = "row">
             <div class = "col m4 l3 yellow">
                <p>This text will use 12 columns on a small screen, 4 on a medium screen (m4),
                   and 3 on a large screen (l3).</p>
             </div>
    
             <div class = "col s4 m8 l9 grey">  
                <p>This text will use 4 columns on a small screen (s4), 8 on a medium screen
                   (m8), and 9 on a large screen (l9).</p>
             </div>
          </div>
       </body>
    </html>