Orsi
Orsi

Reputation: 575

Moving Bootstrap modal on page

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!

Upvotes: 3

Views: 16915

Answers (2)

chv
chv

Reputation: 105

.modal-content{
    margin-top:50px !important;
}

Upvotes: 0

Karan Mehta
Karan Mehta

Reputation: 415

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>  

Upvotes: 10

Related Questions