Tuesday, March 7, 2017

Materialize - Dropdowns

The Materialize provides dropdown CSS class to make a ul element as a dropdown and add the id of the ul element to the data-activates attribute of the button or anchor element.The below table mentions the available classes and their effects.

S.N.Class Name & Description
1dropdown-content
Identifies ul as an materialize dropdown component. Required for ul element.
2data-activates
id of the dropdown ul element.
Following are the examples of using a dropdown.

Example

materialize_dropdowns.htm
<!DOCTYPE html>
<html>
   <head>
      <title>The Materialize Dropdowns 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 class="container"> 
   <h3>Drop Down Demo</h3>
      <ul id="dropdown" class="dropdown-content">
         <li><a href="#">Inbox<span class="badge">12</span></a></li>
         <li><a href="#!">Unread<span class="new badge">4</span></a></li>
         <li><a href="#">Sent</a></li>
   <li class="divider"></li>
   <li><a href="#">Outbox<span class="badge">14</span></a></li>
      </ul>
      <a class="btn dropdown-button" href="#" data-activates="dropdown">Mail Box<i class="mdi-navigation-arrow-drop-down right"></i></a>  
   </body>
</html>

Result

Verify the result.

No comments:

Post a Comment