Modal close button without title is left aligned
See original GitHub issueHello,
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">×</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
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
Hey @Johann-S , I think adding
ml-auto
tobutton.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#L28Should I raise a PR? I’m planning to squash some bugs in the coming days. Let me know guys.