I define a Bootstrap 5 toast like this:
<div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Help</strong>
<button type="button" class="end-0 close" data-dismiss="toast">
<span>×</span>
</button>
</div>
...
</div>
hoping the end-0
class would align the Close button character ×
to the right border of the toast. Instead the class does nothing. Other placement classes like m-2
do work.
Can I do this with a Bootstrap placement class or do I have to add manual CSS for this?
2
Answers
use ‘float-end’ Bootstrap 5 class to move the element to the right side.
For Bootstrap 4, use ‘pull-right’ or ‘float-right’ class.
It seems you are using Bootstrap 4.
You need to add the "justify-content-between" class to the "toast-header" class. This will align the close button to the right. Here’s how you can do it: