06 October 2012

Web Tip: Twitter bootstrap modal custom width


I was working with one web application based on twitter boostrap. There was an issue with modal poup width. My solution fixed the problem:

Javascript code to show the modal:


$('# myModal ').modal({
  show: true,
}).css({
        width: '900px',
        'margin-left': function () {
            return -($(this).width() / 2);
        }
    });

HTML code part


  1. <-- Modal -->
  2. <div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  3. <div class="modal-header">
  4. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  5. <h3 id="myModalLabel">Modal header</h3>
  6. </div>
  7. <div class="modal-body">
  8. <p>One fine body…</p>
  9. </div>
  10. <div class="modal-footer">
  11. <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
  12. <button class="btn btn-primary">Save changes</button>
  13. </div>
  14. </div>

1 comment:

  1. I created a quick tutorial here covering the same topic, would you tell me what you think? :) twitter bootstrap modal width

    ReplyDelete