Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top navbar overlaps with main content

I'm converting my landing page from Bootstrap to Semantic-UI. The page has a position fixed top navbar. The main content is divided in two columns (3-cols and 9-cols). The left column is used to show a sidebar and the right column is used for current content.

I tried to copy and paste the demo page of Semantic-UI. The navbar is 45px high. I noticed that the first 45px of main content is overlapped.

<link href="//semantic-ui.com/dist/semantic.min.css" rel="stylesheet"/>
<script src="//semantic-ui.com/dist/semantic.min.js"></script>

<div id="navbar" class="ui fixed inverted main menu">
  <div class="container">
    <div class="title item">
      <b>Dashboard</b>
    </div>
  </div>
</div>

<div id="maincontent" class="ui bottom attached segment pushable">
    
  <div id="sidebar" class="ui visible left vertical sidebar menu">
    <a class="item">First Item</a>
    <a class="item">Second Item</a>
    <a class="item">Third Item</a>
    <a class="item">Fourth Item</a>
    <a class="item">Fifth Item</a>
  </div>
    
  <div id="content" class="pusher">
    <div class="ui basic segment">
      <h3 class="ui header">Application Content</h3>
      <p>First paragraph...</p>
      <p>Second paragraph...</p>
      <p>Third paragraph...</p>
    </div>
  </div>

</div>

My current workaround is to add a 45px high placeholder after navbar.

<div style="height:45px"></div>

I'm pretty sure there are some good css style names can fix the content overlapping.

like image 664
stanleyxu2005 Avatar asked Feb 20 '15 10:02

stanleyxu2005


People also ask

How do you make navbar not overlap?

Div Overlapping Navbar Bootstrap You can also select to combine your other content by selecting the fixed menu. Setting the top menu to be fixed by default is as simple as using position:fixed and top:0. In order to fix this, you must add a margin-top equal or larger than the height of your menu.

How do I fix a navbar top to fixed?

To create a fixed top menu, use position:fixed and top:0 . Note that the fixed menu will overlay your other content. To fix this, add a margin-top (to the content) that is equal or larger than the height of your menu.

How do I make my navbar overlap?

Hello there, To make the nav bar and top bar scroll normally, you may go to Appearance > Customize > Header > Navbar Position > Select: Static Top.

What is navbar static top?

According to the documentation of the Bootstrap 3's navbar static-top, Static top Create a full-width navbar that scrolls away with the page by adding . navbar-static-top and include a . container or . container-fluid to center and pad navbar content.


1 Answers

The solution is much simpler. You just need to add a padding to your main container:

<div id="navbar" class="ui fixed inverted main menu">
 <!-- header content here -->
</div>
<div id="content" class="ui container">
 <!-- main content here -->   
</div>

And add in your CSS:

.ui#content{
  // padding should be the same as header height
  padding-top: 55px;
}
like image 82
Ronen Avatar answered Sep 19 '22 18:09

Ronen