I am currently enhancing the appearance of my navbar by adding two "Stripes" on top. I am using bootstrapv4 as a base, but facing an issue where bootstrap centers my decorations. How can I prevent this?
Below is a simplified version of my code:
HTML:
<nav class="navbar navbar-expand-lg navbar-green">
<div class="navbar-top-bg"></div>
<div class="container">
<div class="navbar-top-fg"></div>
</div>
</nav>
CSS:
.navbar-top-bg {
position: absolute;
content: "";
width: 100%;
height: 10px;
background: rgba(67, 107, 65, 0.5);
margin: 0 auto;
z-index: 111111;
border-bottom: 1px solid rgba(87, 136, 89, 0.4);
vertical-align: top;
}
.navbar-top-fg {
position: relative;
content: "";
width: 288px;
height: 10px;
-webkit-transform: perspective(40px) rotateX(-16deg);
transform: perspective(40px) rotateX(-16deg);
background: rgba(0, 0, 0, 0.5);
margin: 0 auto;
z-index: 1111111;
/*border-bottom: 2px solid rgba(234, 234, 234, 0.4);*/
border-right: 2px solid rgb(65, 100, 62);
border-left: 2px solid rgb(65, 100, 62);
vertical-align: top;
}
.navbar-green {
padding-left: 0;
padding-right: 0;
background: rgba(37, 48, 27, 1);
background: -moz-linear-gradient(top, rgba(39, 41, 37, 1) 0%, rgba(0, 0, 0, 0.60) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(39, 41, 37, 1)), color-stop(100%, rgba(0, 0, 0, 0.60)));
background: -webkit-linear-gradient(top, rgba(39, 41, 37, 1) 0%, rgba(0, 0, 0, 0.60) 100%);
background: -o-linear-gradient(top, rgba(39, 41, 37, 1) 0%, rgba(0, 0, 0, 0.60) 100%);
background: -ms-linear-gradient(top, rgba(39, 41, 37, 1) 0%, rgba(0, 0, 0, 0.60) 100%);
background: linear-gradient(to bottom, rgba(39, 41, 37, 1) 0%, rgba(0, 0, 0, 0.60) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#25301b', endColorstr='#79bd64', GradientType=0);
border-bottom: 1px solid rgba(91, 115, 89, 0.08) !important;
-webkit-box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.75);
height: 75px;
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
The green stripes in the design are appearing vertically centered within the navbar, but my preference is to display them at the top. To visualize this layout adjustment, you can remove the navbar
and navbar-expand-lg
classes. Additionally, I would like to retain the common "navbar" features for incorporating links and other elements.
For reference, here is the link to the jsfiddle: