I have a webpage featuring a Bootstrap 4 toast with the position set as position: fixed
. The entire code snippet for the toast section is shown below:
<div class="container mt-5">
<button type="button" class="btn btn-primary" id="liveToastBtn">Toast it</button>
<div id="toastContainer" style="position: fixed; top: 1.5vw; right: 1vw; bottom: 4.5vw; z-index: 9;">
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="..." class="rounded mr-2" alt="...">
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div>
</div>
To view the complete functioning code, refer to this JSFiddle link.
While the toast works perfectly as is, I now wish to adjust the width of the toast to approximately 50% of the viewport. I attempted setting the width
property within the
<div id="toastContainer"...
line:
<div id="toastContainer" style="position: fixed; top: 1.5vw; width: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;">
Alternatively, I also tested setting left
:
<div id="toastContainer" style="position: fixed; top: 1.5vw; left: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;">
However, in both scenarios, only the horizontal position of the displayed toast changes, not its width.
What steps can be taken to adjust the width of this Bootstrap 4 toast accordingly?