Materialize Material Box And sliders

in this tutorial, you will learn about Materialize Material Box and sliders. Each and every concept is mentioned with the help of different examples.

Materialize Box

Material box is basically a material design implementation of the lightbox plugin. Whenever, user clicks on the image then Material Box enlarge the image as well as center the image smoothly.

Example

How To Create Materialize Box

To create Materialize Box follow the following steps.

  • Step:1 - Add the .materialboxed class to the <img> image element base class.
    Collapsible Header & Body
    
        <img class="materialboxed" src="..."  alt="Material Box">          
       
  • Step:2 - Initialize Materialize Box using Javascript or jQuery.
    Initialization
    
        //Javascript
     document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.materialboxed');
        var instances = M.Materialbox.init(elems, options);
      });
    
     // Or with jQuery
    
     $(document).ready(function(){
        $('.materialboxed').materialbox();
      });
       

General Syntax

    <img class="materialboxed" src="..."  alt="Material Box">
     
Try It Now

Material Box Caption

It is very easy to add a short caption to your photo. Just add the caption as a data-caption attribute.

Example

General Syntax

    <img class="materialboxed" data-caption="Write down caption of the image" alt="Caption concept" >
     
Try It Now

Source Code

     
      <img class="materialboxed" data-caption="This is a beautiful picture." src="../code-support/images/slider/bird.jpg" alt="Caption concept">     
    
Try it yourself

Materialize Slider

It is a simple and elegant image carousel that also contains captions that will be transitioned on their own depending on their alignment. It shows the slider indicators on the bottom of the slider.

Example

How To Create Materialize Slider

To create Materialize Slider follow the following steps.

  • Step:1 - Add .slider class to the slider container element i.e <div>.
    Slider Container
    
        <div class="slider"></div>
       
  • Step:2 - Add .slides class to the <ul> element class and put it inside the slider container.
    Slides
      
      <div class="slider">
         <ul class="slides"></ul>
      </div>  
       
  • Step:3 - Write down slider content inside the unordered list items.
    Slider Content
       
    <div class="slider">
    <ul class="slides">
       <li>
        <img src=".." alt="Slider Image"> 
          <div class="caption center-align">
            <h3>Slider Heading</h3>
            <h5 class="light grey-text text-lighten-3">Slider Sub Heading.</h5>
          </div>
       </li>   
    </ul>
    </div>  
       
  • Step:4 - Initialize the slider using either Javascript or jQuery.
    Initialization
       
       //Javascript 
     document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.slider');
        var instances = M.Slider.init(elems, options);
      });
      // Or with jQuery
      $(document).ready(function(){
        $('.slider').slider();
      });
       

Source Code

     
      <div class="slider">
    <ul class="slides">
      <li>
        <img src="https://lorempixel.com/580/250/nature/1"> <!-- random image -->
        <div class="caption center-align">
          <b>This is our big Tagline!</b>
          <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
        </div>
      </li>
      <li>
        <img src="https://lorempixel.com/580/250/nature/2"> <!-- random image -->
        <div class="caption left-align">
          <b>Left Aligned Caption</b>
          <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
        </div>
      </li>
      <li>
        <img src="https://lorempixel.com/580/250/nature/3"> <!-- random image -->
        <div class="caption right-align">
          <b>Right Aligned Caption</b>
          <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
        </div>
      </li>
      <li>
        <img src="https://lorempixel.com/580/250/nature/4"> <!-- random image -->
        <div class="caption center-align">
          <span>This is our big Tagline!</span>
          <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
        </div>
      </li>
    </ul>
  </div>     
    
Try it yourself

Fullscreen Slider

You can easily make full screen slider by adding the fullscreen class to the slider div having .slider class.

Example

General Syntax

    <div class="slider fullscreen">
  <ul class="slides"></ul>
</div>
     
Try It Now

Source Code

     
      <div class="slider fullscreen">
  <ul class="slides">
    <li>
      <img src="../code-support/images/slider/bird.jpg"> <!-- random image -->
      <div class="caption center-align">
        <b>This is our big Tagline!</b>
        <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
      </div>
    </li>
    <li>
      <img src="../code-support/images/slider/lily.jpg"> <!-- random image -->
      <div class="caption left-align">
        <b>Left Aligned Caption</b>
        <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
      </div>
    </li>
    <li>
      <img src="../code-support/images/slider/rose.jpg"> <!-- random image -->
      <div class="caption right-align">
        <b>Right Aligned Caption</b>
        <p class="light grey-text text-lighten-3">Here's our small slogan.</p>
      </div>
    </li>
  </ul>
</div>     
    
Try it yourself

Web Tutorials

Materialize Material Box And Sliders
Html Tutorial HTML
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4
Materialize CSS Tutorial MATERIALIZE CSS