-
-
Save JulaineScott/9e44d9830276a3e3b0eb5f73f6cd9f37 to your computer and use it in GitHub Desktop.
Sticky Announcement Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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%); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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">×</span> | |
</button> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://anhkarppinen.com/sticky-announcement-bar-bootstrap/