question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal close button without title is left aligned

See original GitHub issue

Hello,

if you create a modal without a title, the close button is not aligned right but left.

<div class="modal fade">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary">Save changes</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

For testing, you could just remove the title from the modals on the example page via the browser inspector: http://v4-alpha.getbootstrap.com/components/modal/#examples

modal

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
PurvaAcommented, May 17, 2017

@bembelimen, I faced same problem. To fix this issue I modified few classes in Modal component. Here is the list of classes:

.modal-header { display: block!important; } .modal-title { float: left; } .modal-header .close { float: right; }

With these adjustments, my issue is fixed. You can check my fiddle https://jsfiddle.net/ue89kxmg/. Click on ‘Launch demo modal’ button to get the Modal

1reaction
shankara-subramanicommented, May 15, 2017

Hey @Johann-S , I think adding ml-auto to button.close should fix the issue. I had issues in running npm in my machine (strange). But this should fix the issue => https://github.com/shankariyerr/bootstrap/blob/22616/scss/_close.scss#L28

Should I raise a PR? I’m planning to squash some bugs in the coming days. Let me know guys.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Left & right align modal footer buttons in Bootstrap 4
Now that the modal-footer is "display:flex" in Bootstrap 4, it would be easiest to use the auto-margins. Use mr-auto on the left button....
Read more >
How to change the position of modal close button in bootstrap?
Approach: In the above, you can observe a button with class = “close” inside the modal header. This button is used for closing...
Read more >
What's the rationale for having the close button on the left ...
They decided to the main button on the left and the button placement does not break natural human behavior, where “yes” is followed...
Read more >
Modal · Bootstrap v5.2
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
Bootstrap 4 modal button align on Codeply
<div class="modal-dialog" role="document">. <div class="modal-content">. <div class="modal-header">. <h5 class="modal-title" id="exampleModalLabel">Modal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found