htmlcsssemantic-uisemantic-ui-css

How to keep vertical menu items from going behind top fixed menu in Semantic UI?


I'm trying to have both a top fixed menu and a left vertical menu on my website. I really want both to be fixed but if I start to scroll then the left vertical menu will slide up underneath the top menu as shown in the code below and the jsfiddle:

<div class="ui inverted top fixed menu">
  <div class="header item">
    Top Menu Header
  </div>
</div>
<div class="ui grid">
  <div class="four wide column">
    <div class="ui inverted left vertical fluid menu" id="side-menu">
      <div class="item">
        Item #1
      </div>
      <div class="item">
        Item #2
      </div>
    </div>
  </div>
  <div class="twelve wide column">
  <!-- Main content here -->
    <div class="row">
      Text here
    </div>
    <div class="row">
      Text here
    </div>
  </div>
</div>

https://jsfiddle.net/318ruL3j/2/

If I use a fixed vertical menu, then the first item is hidden underneath the top menu as shown in the code below and the jsfiddle:

<div class="ui inverted left vertical fixed menu" id="side-menu">
  <div class="item">
    Item #1
  </div>
  <div class="item">
    Item #2
  </div>
</div>
<div class="ui inverted top fixed menu">
  <div class="header item">
    Top Menu Header
  </div>
</div>
<div class="ui grid">
  <!-- Main content here -->
  <div class="column">
    <div class="row">
      Text here
    </div>
    <div class="row">
      Text here
    </div>
  </div>
</div>

https://jsfiddle.net/z5vozbts/2/

I hope what I'm trying to do makes sense. Does anyone know how I can have both of these fixed menus without my items getting overlapped?


Solution

  • Thanks for the answers. I ended up using jQuery to make my solution a little more dynamic because my top fixed menu can vary in height. I changed the top padding of the body to match the height of the top menu using this code:

    $('body')
        .css('padding-top', $('#top-menu').height());
    

    Adding padding to the top of the body pushes down the ui grid containing my side menu.