Moving Bootstrap modal on page

11,649

I think You Need This :)

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<div>
<div class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal --> 
</div>

<script>
        $('.modal').modal({ keyboard: false,
                           show: true
        });
        // Jquery draggable
        $('.modal-dialog').draggable({
            handle: ".modal-header"
        });
</script>  
Share:
11,649

Related videos on Youtube

Orsi
Author by

Orsi

Updated on June 04, 2022

Comments

  • Orsi
    Orsi about 2 years

    I have a bootstrap modal on the screen. When the modal is showed, it is positioned on the center of the screen.

    <div class="modal fade" id="ua_dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <div class="modal-body">
            ....
            </div>
          </div>
    

    I need to move the modal on my screen, because cover some information from my screen. The user should be able to move on the right, on the left...etc. Can I do that? there is some settings that I can use? or with js? what is the best way? Thanks!

    • CBroe
      CBroe over 6 years
    • CBroe
      CBroe over 6 years
      “I need to move the modal on my screen, because cover some information from my screen.” - if you have information outside the modal that still needs to be accessible, that might rather suggest that a modal is the wrong thing to use here in the first place ...
    • Orsi
      Orsi over 6 years
      It covers a map which needs to be visible. Can I make the modal to be movable? Or I need to position the modal to be for example on the right of the screen?
    • CBroe
      CBroe over 6 years
      “Can I make the modal to be movable?” - can you please start doing your own basic research …? stackoverflow.com/q/12591597/1427878
  • chv
    chv over 6 years
    use !important in your css