cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <h2>Bootstrap 3 Custom Modals Demo</h2>

<!-- Link triggered modal -->
<p><a href="#" 
      data-toggle="modal" 
      data-target="#customPositionModal">Click to open a Modal with custom positioning</a></p>
   
<!-- Button triggered modal -->
<p><button type="button" 
        class="btn btn-primary btn" 
        data-toggle="modal" 
        data-target="#customPositionModal">
  Click to open a Modal with custom positioning
  </button></p>

<hr>
<!-- Link triggered modal -->
<p><a href="#" 
      data-toggle="modal" 
      data-target="#customSizeModal">Click to open a custom-sized Modal</a></p>
   
<!-- Button triggered modal -->
<p><button type="button" 
        class="btn btn-success" 
        data-toggle="modal" 
        data-target="#customSizeModal">
  Click to open a custom-sized Modal
  </button></p>

<hr>
<!-- Link triggered modal -->
<p><a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-muted">Default</a>
   &nbsp;
   <a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-primary">Primary</a>
   &nbsp;
   <a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-success">Success</a>
   &nbsp;
   <a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-info">Info</a>
   &nbsp;
   <a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-warning">Warning</a>
   &nbsp;
   <a href="#" 
      data-toggle="modal" 
      data-target="#customHeaderModal"
      class="text-danger">Danger</a>
</p>

<!-- Button triggered modal -->
<p><button type="button" 
        class="btn btn-muted" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Default
  </button>
  &nbsp;
  <button type="button" 
        class="btn btn-primary" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Primary
  </button>
  &nbsp;
  <button type="button" 
        class="btn btn-success" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Success
  </button>
  &nbsp;
  <button type="button" 
        class="btn btn-info" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Info
  </button>
  &nbsp;
  <button type="button" 
        class="btn btn-warning" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Warning
  </button>
  &nbsp;
  <button type="button" 
        class="btn btn-danger" 
        data-toggle="modal" 
        data-target="#customHeaderModal">
  Danger
  </button>
</p>

<!-- Modal DIVS -->
<div class="modal fade" id="customPositionModal" tabindex="-1" role="dialog" aria-labelledby="customPositionModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Custom Positioned Modal</h4>
            </div>
            <div class="modal-body">
                <p>Hi, I'm a Modal with custom positioning of:</p>
                <pre>
#customPositionModal {
  top:5%;
  right:50%;
  outline: none;
}
                </pre>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
  </div>
</div>

<div class="modal fade" id="customSizeModal" tabindex="-1" role="dialog" aria-labelledby="customSizeModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Custom Size Modal</h4>
            </div>
            <div class="modal-body">
              <p>Hi, I'm a custom-sized Modal with a width of <span id="width"></span>.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
  </div>
</div>

<div class="modal fade" id="customHeaderModal" tabindex="-1"
    role="dialog" aria-labelledby="customHeaderModal" aria-hidden="true">
  <div class="modal-dialog">
      <div class="modal-content panel-default">
          <div class="modal-header panel-heading">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title"></h4>
          </div>
          <div class="modal-body">
              <h3>Modal Body</h3>
          </div>
          <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
  </div>
</div>


<br/>
<br/>
<hr size="2" />
<p>If you find this demo useful, please consider <a href="https://paypal.me/RobertGravelle/1" target="_blank">donating $1 dollar</a> (secure PayPal link) for a coffee or purchasing one of my songs from <a href="http://ax.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=rob%20gravelle" target="_blank">iTunes.com</a> or <a href="http://www.amazon.com/s/ref=ntt_srch_drd_B001ES9TTK?ie=UTF8&field-keywords=Rob%20Gravelle&index=digital-music&search-type=ss" target="_blank">Amazon.com</a> for only 0.99 cents each. </p>
<p>Rob uses and recommends <a href="http://www.mochahost.com/2425.html" target="_blank">MochaHost</a>, which provides Web Hosting for as low as $1.95 per month, as well as unlimited emails and disk space!</p>

            
          
!
            
              body { text-align: center; }

#customPositionModal {
  top:5%;
  right:50%;
  outline: none;
}

#customSizeModal .modal-dialog  { 
  width: 75%; 
}

pre {
  text-align: left;
}

@media screen and (min-width: 768px) {
	#customSizeModal .modal-dialog { 
    width: 50%; 
  }
}

a[data-target="#customHeaderModal"] {
  text-decoration: underline; 
} 

.panel-heading {
    border-top-left-radius: inherit; 
    border-top-right-radius: inherit;
}
            
          
!
            
              jQuery.fn.extend({
  swapClass: function(oldClassRegex, newClass, animationSpeed) {
      animationSpeed = animationSpeed || 500;
      return this.removeClass(function(index, className) {
          return (className.match(oldClassRegex) || [])[0];
      }).addClass( newClass, animationSpeed );
  }
});

$('#customSizeModal').on('show.bs.modal', function() {
    var rules = document.styleSheets[1].rules || document.styleSheets[1].cssRules,
        mql   = window.matchMedia("screen and (min-width: 768px)"),
        width;
  
    for (var i=0; i<rules.length && !width; i++) {
      var rule = rules[i];
      if (  mql.matches === true
            &&  rule.parentRule 
            && rule.parentRule.type === CSSRule.MEDIA_RULE
          || mql.matches === false 
            && rule.type === CSSRule.STYLE_RULE
            && rule.selectorText == '#customSizeModal .modal-dialog') {
        width = rule.style.getPropertyValue("width");
      }
      else if (  mql.matches === true 
              && rule.type === CSSRule.MEDIA_RULE) {
        for (var j=0; j<rule.cssRules.length && !width; j++) {
          var mediaRule = rule.cssRules[j];
          if (mediaRule.selectorText == '#customSizeModal .modal-dialog') {
            width = mediaRule.style.getPropertyValue("width");
          }
        }
      }
    }
    $(this).find("#width").text(width);
});

$('#customHeaderModal').on('show.bs.modal', function(event) {
  var label = $(event.relatedTarget).text().trim();
  $(this).find('.modal-content')
         .swapClass(/\bpanel-\w+\b/, 
                    'panel-' + label.toLowerCase())
         .find('.modal-title').text(label + ' Header');
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console