Semantic UI centered non-fluid menu?
Asked Answered
S

4

14

I have two menus, one is fixed to the bottom and another fixed to the top. My problem is two-fold. I want them to appear at the center of the screen and only be the width of their content (instead of being fluid, as per default).

I have found nothing in the documentation to indicate that this is possible, so presumably the solution is to modify it with CSS?

Any help would be greatly appreciated.

Soult answered 25/4, 2015 at 4:54 Comment(0)
L
21

Use the semantic ui class "compact" for your UI menus to adjust to content, and then use grids and columns for center alignment. So for example:

<div class="ui centered grid">
    <div class="center aligned column">
        <div class="ui compact menu">
          <a class="active item">
            <i class="home icon"></i> Home
          </a>
          <a class="item">
            <i class="mail icon"></i> Messages
          </a>
        </div>        
    </div>
</div>

JSFiddle Link: http://jsfiddle.net/pLskpufp/2/

Linnea answered 14/5, 2015 at 1:1 Comment(1)
This also seems to fail when you make the menu fixedTasman
O
3

You can also just use a center aligned container:

<div class="ui center aligned container">
    <div class="ui compact menu">
        <a class="active item">
            <i class="home icon"></i> Home
        </a>
        <a class="item">
            <i class="mail icon"></i> Messages
        </a>
    </div>        
</div>

JSFiddle Link: http://jsfiddle.net/377v6ect/1/

Omalley answered 4/5, 2016 at 6:11 Comment(1)
This seems to fail when using fixed class on the menuTasman
C
1

I know it's not a pure Semantic UI solution, but for those of you looking for a way to do this with a fixed menu in Semantic UI, the best solution I've found so far is to wrap it in a div with a little custom CSS.

<div className="fixed bottom">
  <div className="ui centered grid">
    <div className="center aligned column">
        <!-- Your Semantic UI menu here, but not fixed. -->
    </div>
  </div>
</div>

Along with this css...

div.fixed {
  width: 100%;
  position: fixed;
}
div.fixed.bottom {
  bottom: 0;
}
div.fixed.top {
  top: 0;
}
Clothesbasket answered 7/11, 2017 at 3:46 Comment(0)
W
0

I have searched on the semantic forums and other places; created mine.. Hope works for you too.

   <div class="ui center aligned container">
    <div class="ui" style="background-color: #009999;">
      <!-- <a href="https://semantic-ui.com/examples/fixed.html#" class="header item"> -->
        <div class="ui centered small image" >
            <a href="#">
            <img class="logo" src="./logo_white.png">
            </a>
        </div>
    <!-- </a> -->
    </div>
</div>
Whitesmith answered 17/10, 2018 at 10:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.