navbar overwrites the other elements when the page size is changed

Asked

Viewed 70 times

1

I have this fictitious application in R.

I tried to adjust the .navbar, .sidebar and the .value-box with the property position: relative; to avoid overlapping of elements:

.navbar {
  position: relative;
}

.sidebar {
  position: relative; 
}

.value-box {
  position: relative;
}

But, always the .navbar runs over the other elements in the case .sidebar and the .value-box when I modify the screen size:

inserir a descrição da imagem aqui

My goal is to get the .navbar Equal descend occurs now, but the other elements need to descend/adjust to not be swallowed by .navbar. Something like that:

inserir a descrição da imagem aqui

1 answer

1


Remove from body whichever padding-top and insert the code below on the page (at the end of the body):

$(window).on("load resize", function(){
   let navHeader = 0;
   if($("#dashboard-container").offset().top < $(".navbar-header").outerHeight()) navHeader = $(".navbar-header").outerHeight();
   $("#dashboard-container").css({"top": ($(".navbar-fixed-top").outerHeight()+10+navHeader) +"px", "position" : "relative"});
   $("#section-sidebar").css("top", ($(".navbar-fixed-top").outerHeight()+10) +"px");
});

By CSS you can’t tell the height of the navbar, so it sits on top of the elements below when it gets bigger, just putting padding-top no body is not enough, since navbar height may vary.

The above code detects when the page loads or when the window resizes and repositions the side (which is fixed) and dahsboard div according to navbar height.

If you can’t find where the padding-top no body is inserted, just set in your custom CSS (the one you created. If you didn’t create one, create one) and put:

body{
   padding-top: 0 !important;
}

This will overwrite any other CSS that might be adding the padding-top to the body.

  • Thanks for the answer, @Sam. Just one detail: when I replay the page, it gets a big gap between the elements and the .navbar. After changing the screen size and returning to normal size, everything is fine. I would like that when processing the page, it was already the right way. Do you know what this might be? In addition, how to remove the scroll from the page of the Carousel?

  • When you’re online let me know.

  • I’m online @Sam, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.