2

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?

ccmetz92
  • 82
  • 8

3 Answers3

2

A quick CSS entry?

#side-menu {
  height: 100vh;
  padding-top:2.0em;  
}
Duane Lortie
  • 1,285
  • 1
  • 12
  • 16
2

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.

ccmetz92
  • 82
  • 8
1

make an empty area above of your vertical menu, means enlarge your menu with an invisible element that has a same height as your fixed element

#side-menu {
  height: 100%;
}
.fake_area {
  position:relative;
  display:block;
  width:100%;
  height:40px;
}

.
.
.
  <div class="header item">
    Top Menu Header
  </div>
</div>
<div class="fake_area"></div>
<div class="ui grid">
  <div class="four wide column">
.
.
.

check it

payam_sbr
  • 1,428
  • 1
  • 15
  • 24