Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <ul class="row first">
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Rocking the night away"  src="http://demo.michaelsoriano.com/images/photodune-174908-rocking-the-night-away-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Yellow sign"  src="http://demo.michaelsoriano.com/images/photodune-287182-blah-blah-blah-yellow-road-sign-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Colors"  src="http://demo.michaelsoriano.com/images/photodune-460760-colors-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Retro party"  src="http://demo.michaelsoriano.com/images/photodune-461673-retro-party-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Technology soup"  src="http://demo.michaelsoriano.com/images/photodune-514834-touchscreen-technology-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Legal docs"  src="http://demo.michaelsoriano.com/images/photodune-916206-legal-xs.jpg" data-bsp-large-src="http://demo.michaelsoriano.com/images/photodune-916206-legal-large.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Nature shot"  src="http://demo.michaelsoriano.com/images/photodune-1062948-nature-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Kid with camera" src="http://demo.michaelsoriano.com/images/photodune-1471528-insant-camera-kid-xs.jpg" data-bsp-large-src="http://demo.michaelsoriano.com/images/photodune-1471528-insant-camera-kid-large.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Relax and Chill" src="http://demo.michaelsoriano.com/images/photodune-2255072-relaxed-man-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Cool colors" src="http://demo.michaelsoriano.com/images/photodune-2360379-colors-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Jump over"  src="http://demo.michaelsoriano.com/images/photodune-2360571-jump-xs.jpg">
            </li>
            <li class="col-md-3 col-sm-6 col-xs-12">
                <img alt="Culture business" src="http://demo.michaelsoriano.com/images/photodune-2361384-culture-for-business-xs.jpg">
            </li>

      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Spaghetti bitch" src="http://demo.michaelsoriano.com/images/photodune-2441670-spaghetti-with-tuna-fish-and-parsley-s.jpg">
      </li>
      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Budget this"  src="http://demo.michaelsoriano.com/images/photodune-2943363-budget-xs.jpg">
      </li>
      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Street art"  src="http://demo.michaelsoriano.com/images/photodune-3444921-street-art-xs.jpg">
      </li>


      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Insurance and stuff"  src="http://demo.michaelsoriano.com/images/photodune-3552322-insurance-xs.jpg">
      </li>

      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Food Explosion"  src="http://demo.michaelsoriano.com/images/photodune-3807845-food-s.jpg">
      </li>
      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Office worker sad" src="http://demo.michaelsoriano.com/images/photodune-3835655-down-office-worker-xs.jpg">
      </li>

      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="" src="http://demo.michaelsoriano.com/images/photodune-4619216-ui-control-knob-regulators-xs.jpg">
      </li>

      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Health" src="http://demo.michaelsoriano.com/images/photodune-5771958-health-xs.jpg">
      </li>
      <li class="col-md-3 col-sm-6 col-xs-12">
          <img  alt="Constant consecutuir" src="http://demo.michaelsoriano.com/images/photodune-268693-businesswoman-using-laptop-outdoors-xs.jpg"><!--no alt tag-->
      </li>
      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Search code" src="http://demo.michaelsoriano.com/images/photodune-352207-search-of-code-s.jpg">
      </li>

      <li class="col-md-3 col-sm-6 col-xs-12">
          <img alt="Pountac" src="http://demo.michaelsoriano.com/images/photodune-247190-secret-email-xs.jpg"><!--no alt tag, no text-->
      </li>
    <li class="col-md-3 col-sm-6 col-xs-12">
        <img alt="Budget again" src="http://demo.michaelsoriano.com/images/photodune-2943363-budget-xs.jpg">
    </li>
    <li class="col-md-3 col-sm-6 col-xs-12">
        <img alt="Some alt tag" src="http://demo.michaelsoriano.com/images/photodune-3444921-street-art-xs.jpg"><!--no alt-->
    </li>
    <li class="col-md-3 col-sm-6 col-xs-12">
        <img alt="Insurance boy"  src="http://demo.michaelsoriano.com/images/photodune-3552322-insurance-xs.jpg">
    </li>
    <li class="col-md-3 col-sm-6 col-xs-12">
        <img alt="Food service"  src="http://demo.michaelsoriano.com/images/photodune-3807845-food-s.jpg">
    </li>
    <li class="col-md-3 col-sm-6 col-xs-12">
        <img alt="Dopamine high"  src="http://demo.michaelsoriano.com/images/photodune-3835655-down-office-worker-xs.jpg">
    </li>

  </ul>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-body">
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
              
            
!

CSS

              
                ul {
  padding:0 0 0 0;
  margin:0 0 0 0;
  display:flex;
  flex-wrap: wrap;
}
ul li {
  list-style:none;
  margin-bottom:25px;
  background: whitesmoke;
}
ul li img {
  cursor: pointer;
  width: 100%;
}

.modal-body img {
  width: 100%;
}
              
            
!

JS

              
                $(document).ready(function(){
   $('li img').on('click',function(){
        var src = $(this).attr('src');
        var img = '<img src="' + src + '" class="img-responsive"/>';
      
       //Start of new code
        var index = $(this).parent('li').index();
        var html = '';
        html += img;
        html += '<div style="height:25px;clear:both;display:block;">';
        html += '<a class="controls next" href="'+ (index+2) + '">next &raquo;</a>';
        html += '<a class="controls previous" href="' + (index) + '">&laquo; prev</a>';
        html += '</div>';
        //End of new code

        $('#myModal').modal();
        $('#myModal').on('shown.bs.modal', function(){
            $('#myModal .modal-body').html(html);
        });
        $('#myModal').on('hidden.bs.modal', function(){
            $('#myModal .modal-body').html('');
        });
   });
});

 $(document).on('click', 'a.controls', function(){
   //this is where we add our logic
   var index = $(this).attr('href');
   alert(index);
   var src = $('ul.row li:nth-child('+ index +') img').attr('src');
   $('.modal-body img').attr('src', src);
   var newPrevIndex = parseInt(index) - 1;
   var newNextIndex = parseInt(newPrevIndex) + 2;

   if($(this).hasClass('previous')){
     $(this).attr('href', newPrevIndex);
     $('a.next').attr('href', newNextIndex);
   }else{
     $(this).attr('href', newNextIndex);
     $('a.previous').attr('href', newPrevIndex);
   }
   return false;
 });
              
            
!
999px

Console