Skip to content

Instantly share code, notes, and snippets.

@JulaineScott
Created November 30, 2021 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulaineScott/9e44d9830276a3e3b0eb5f73f6cd9f37 to your computer and use it in GitHub Desktop.
Save JulaineScott/9e44d9830276a3e3b0eb5f73f6cd9f37 to your computer and use it in GitHub Desktop.
Sticky Announcement Header
[insert name of top navbar] {
padding: 20px;
}
.announcement-top-bar {
position: -webkit-sticky;
position: -moz-sticky;
position: -ms-sticky;
position: -o-sticky;
position: sticky;
top: 0;
}
.announcement-top-bar p {
margin: 0;
}
.announcement-top-bar.alert-dismissible .close {
top: 50%;
transform: translateY(-55%);
}
<div class="alert alert-warning alert-dismissible fade show announcement-top-bar" role="alert">
<p class="d-none d-md-block">This is the content of the announcement bar <a href="#" target="_blank" class="btn btn-primary">Click here</a></p>
<p class="d-block d-md-none">This is the content of the announcement bar <a href="#" target="_blank">Click here</a></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
@JulaineScott
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment