I am currently working on creating a web page using Twitter Bootstrap that includes a "floating" (fixed-position) alert at the top. Here is an example of how I have set it up:
HTML:
<div class="container">
<div class="row">
<div class="col-sm-12">
<div id="top-message" class="container row col-sm-12">
<div class="alert alert-danger">
Hi there!
</div>
</div>
</div>
<!-- page content -->
</div>
</div>
CSS:
#top-message {
z-index: 10;
position: fixed;
width: 100%;
}
When viewing this on smaller screens, it looks just as intended:
https://i.sstatic.net/UjeuX.png
However, on larger screens, the alert extends outward like this:
https://i.sstatic.net/fvTU2.png
Simply removing width: 100%
from top-message
is not an option, as I still want the alert to occupy some width even with small text.
What adjustments should I make so that the alert stays centered like on smaller screens, regardless of the screen size being used to view the page?