I have a Navbar hamburger container and I have a text container.
this is the nav container:
.containerham{
width: 100%;
height: max-content;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
position: relative !important;
z-index: 100 !important;
border-bottom: 1px solid grey;
}
and this is the text container:
.headdingtextcon{
width: 17rem;
justify-self: center;
align-self: center;
height: min-content;
padding: 0.5rem;
position: relative !important;
top: -5rem;
left: -1.5rem;
font-size: 2rem;
z-index: 1 !important;
}
I want my nav container to overlap my text container but it dose the opposite:
enter image description here
For context my navbar has a animation on it that might help
.slideInDown {
-webkit-animation-name: slideInDown;
animation-name: slideInDown;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes slideInDown {
0% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
visibility: visible;
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
@keyframes slideInDown {
0% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
visibility: visible;
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
.slideOutUp {
-webkit-animation-name: slideOutUp;
animation-name: slideOutUp;
-webkit-animation-duration: 2s;
animation-duration: 2s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes slideOutUp {
0% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
100% {
visibility: hidden;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
}
@keyframes slideOutUp {
0% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
100% {
visibility: hidden;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
}
The text container is the one that has the sweet word next to it.
2
Answers
Answer
edit:
In your case you have not set a
background-color
orbackground
property on the navbar. Css by default makes your containers transparent, thus showing the text underneath.Code
It appears that you have set the top property plus the position property on your text container.
The top property moves the element relative to its top edge, while the position: relative property positions the element relative to its normal position.
The text container is thus moved below where it should normally be, making space for the navbar to appear above it.
You can test with altering the position and z-index properties on both containers if you want the navbar to cover the text container. For instance, you might change the navbar container’s position property from relative to absolute so that it would not follow the regular flow of the document and could overlap other elements. Then, you can raise its z-index value to guarantee that it will be displayed above the other items. Finally, you may modify the text container’s z-index value to position it below the navbar.