Question

I'm working on an app that has a group of icons in the footer of a column. Currently, the icons are left-justified. However, I'd like to make them centered. To demonstrate, I have a fiddle that can be found here. The HTML looks like the following:

<div class="ui full-height grid">
  <div class="full-height row">
    <div id="navDiv" class="four wide full-height column" style="background-color:navy; color:white;">
      <div id="nav-tab-items" class="row">
        <div class="nav-tab-frame column">
          <div class="ui active tab nav-tab-content" data-tab="home">
              First Tab
          </div>
          <div class="ui tab nav-tab-content" data-tab="info">
            Second Tab
          </div>
          <div class="ui tab nav-tab-content" data-tab="third">
            Third Tab
          </div>
        </div>
      </div>

      <div id="nav-tab-control" class="bottom aligned row">
        <div class="ui pointing secondary menu drawer" style="margin-bottom:0rem;">
          <a class="active red item" data-tab="home">tab 1</a>
          <a class="blue item" data-tab="info">tab 2</a>
          <a class="green item" data-tab="third">tab 3</a>
        </div>
      </div>    
    </div>

    <div class="eight wide full-height column">
      [Content Goes Here]
    </div>
  </div>
</div>

There are two problems with nav-tab-control. First, as soon as I set 'bottom:0' for the , the nav-tab-control style, the row takes up the entire width of the page. I can't repro that error in the fiddle. But I have no idea what would even cause that. Second, and I believe this is related to the first problem, is that I can't figure out how to center the icons within the width of the navDiv.

I sincerely appreciate any insights that someone can provide.

Was it helpful?

Solution

This code centers the buttons at the bottom (I couldn't think if what else you would mean by 'icons').

You say #nav-tab-control is claiming the full width of the screen. That is actually needed to make it possible to center its contents. So because it didn't do it automatically, I've set the width to 100% in the css:

#nav-tab-control { 
    position:absolute; 
    bottom:0;
    left: 0;
    width: 100%;
    text-align: center;
}

.ui.pointing.secondary.menu.drawer { display: inline-block; }

This makes #nav-tab-control the full width of the page, and centers any text in it. Then, the container of the icons is displayed as inline-block, so it respects that centering.

http://jsfiddle.net/62eMj/3/

If you don't want to center it in the whole screen, you can also set position: relative to one of the parent elements. For instance to to center them inside the blue bar (also causing them to wrap):

http://jsfiddle.net/62eMj/4/

I found it a bit hard to find out what your actual problem is. I thought I knew but now I', not so sure. I hope these hints will help you solve it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top