Justify css menu in IE

751 views Asked by At

I want to make a CSS menu auto-justify full width.

HTML:

<nav class="menu">
  <ul>
    <li><a href="#">click</a></li>
    <li><a href="#">click</a></li>
    <li><a href="#">long clickclick</a></li>
    <li><a href="#">click</a></li>
    <li><a href="#">clickclickclick</a></li>
    <li><a href="#">click click 666</a></li>
  </ul>
</nav>

CSS:

.menu {
  text-align: justify;
  font-size: 0;
  font-size: 14px\9; /* IE6-9 hack */
  line-height: 0;
}
.menu:after {
  content: '';
  display: inline-block;
  width: 100%;
  height: 0;
  zoom: 1;
  *display: inline;
}
.menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: inline;
}
.menu ul li {
  display: inline-block;
  font-size: 14px;
  zoom: 1;
  *display: inline;
}
.menu ul li a {
  line-height: 54px;
}

Demo

It working good on Chrome/Firefox, but not working on IE 10-11. Coud someone please help me fix this? What I see: top is Chrome (good), bottom IE11 (bad)

2

There are 2 answers

4
Sinister Beard On

Do you mean you want to have the menu spread across the width of the page? In that case, adding min-width:100%; to .menu in your CSS file will achieve that.

2
user3421719 On

I had the same problem, add text-justify: distribute to your .menu and it will work fine.