0

I want to center the menu menu button in slicknav. I tried but nothing works . I can align it to the left but not in center.

sample mark up is here

<ul id="menu">
    <li><a href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
    <li><a href="#">item 4</a></li>
</ul>

and js

$(function() {
  $('#menu').slicknav();
});

here is codepen link http://codepen.io/anon/pen/oLWpao

Md. Monirul Alom
  • 275
  • 4
  • 16

3 Answers3

1

I found solution to my question.

just added some css

.slicknav_menu {
  display: block;
  text-align: center;
  width: 100%;
}
.slicknav_btn {
  display: inline-block;
  float: none;
  text-align: center;
}

This solved my problem.

here is codepen link: http://codepen.io/anon/pen/OXmQLG

Md. Monirul Alom
  • 275
  • 4
  • 16
0

Check your browser inspect. All the elements are given a display: block, which gives it a full width. If you set the '.slicknav_nav a' on display: inline-block and the li parent a text-center, everything should be what you want.

.slicknav_nav a {
  display: inline-block; // instead of block;
}

.slicknav_nav li {
  text-align: center;
}

This might be some useful info: What is the difference between display: inline and display: inline-block?

Community
  • 1
  • 1
adamk22
  • 581
  • 4
  • 18
0
.slicknav_menu {
    text-align: center;
}

.slicknav_btn { 
    display: inline-block; 
    float: none;
}
Timothy
  • 2,004
  • 3
  • 23
  • 29
chander shekhar
  • 425
  • 2
  • 10