如何将向导左右对齐?

How to align the wizard to the left and right sides?

简单地说,这是我的current code, and I want it looks like this

如何修复 css?

.nav-wizard {
  display: table;
  width: 100%;
}
.nav-wizard > li {
  display: table-cell;
  text-align: left;
}
.nav-wizard > li > a {
  position: relative;
  background-color: #eeeeee;
  padding-left: 30px;
}
.nav-wizard > li > a .badge {
  margin-left: 6px;
  color: #eeeeee;
  background-color: #428bca;
}
.nav-wizard > li:first-child > a {
  padding-left: 20px;
}
.nav-wizard > li:not(:first-child) > a:before {
  height: 0px;
  border-top: 20px inset transparent;
  border-bottom: 20px inset transparent;
  border-left: 20px solid #ffffff;
  position: absolute;
  content: "";
  top: 0;
  left: 0;
}
.nav-wizard > li:not(:last-child) > a {
  margin-right: 6px;
}
.nav-wizard > li:not(:last-child) > a:after {
  width: 0px;
  height: 0px;
  border-top: 20px inset transparent;
  border-bottom: 20px inset transparent;
  border-left: 20px solid #eeeeee;
  position: absolute;
  content: "";
  top: 0;
  right: -20px;
  z-index: 2;
}
.nav-wizard > li:first-child > a {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}
.nav-wizard > li:last-child > a {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}
.nav-wizard > li.done:hover > a,
.nav-wizard > li:hover > a {
  background-color: #d5d5d5;
}
.nav-wizard > li.done:hover > a:before,
.nav-wizard > li:hover > a:before {
  border-right-color: #d5d5d5;
}
.nav-wizard > li.done:hover > a:after,
.nav-wizard > li:hover > a:after {
  border-left-color: #d5d5d5;
}
.nav-wizard > li.done > a {
  background-color: #e2e2e2;
}
.nav-wizard > li.done > a:before {
  border-right-color: #e2e2e2;
}
.nav-wizard > li.done > a:after {
  border-left-color: #e2e2e2;
}
.nav-wizard > li.active > a,
.nav-wizard > li.active > a:hover,
.nav-wizard > li.active > a:focus {
  color: #ffffff;
  background-color: #428bca;
}
.nav-wizard > li.active > a:after {
  border-left-color: #428bca;
}
.nav-wizard > li.active > a .badge {
  color: #428bca;
  background-color: #ffffff;
}
.nav-wizard > li.disabled > a {
  color: #777777;
}
.nav-wizard > li.disabled > a:hover,
.nav-wizard > li.disabled > a:focus {
  color: #777777;
  text-decoration: none;
  background-color: #eeeeee;
  cursor: default;
}
.nav-wizard > li.disabled > a:before {
  border-right-color: #eeeeee;
}
.nav-wizard > li.disabled > a:after {
  border-left-color: #eeeeee;
}
.nav-wizard.nav-justified > li {
  float: none;
}
.nav-wizard.nav-justified > li > a {
  padding: 10px 15px;
}
@media (max-width: 768px) {
  .nav-wizard.nav-justified > li > a {
    border-radius: 4px;
    margin-right: 0;
  }
  .nav-wizard.nav-justified > li > a:before,
  .nav-wizard.nav-justified > li > a:after {
    border: none !important;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="col-md-6">
      <div class="page-header">
        <h1>Nav Wizard Demo</h1>
      </div>

      <ul class="nav nav-wizard">
        <li class="active"><a href="#">Home</a>
        </li>
        <li><a href="#">Profile</a>
        </li>
        <li><a href="#">Messages to looooooooooooonnnngggggggggg</a>
        </li>
      </ul>
      <BR>
      <input type="text" class="form-control">
    </div>
  </div>
</div>

如您所见,向导的右侧未与 input 的右侧对齐(向导的长度不等于输入的长度)。

我需要向导的最后一部分(带有 messages)与 input 的右侧对齐。我该怎么做?

您必须将最后一个项目向右浮动,但这可能不是最佳解决方案。

.nav-wizard > li:last-child {
    float: right;
}

JSFiddle Demo

如果您希望它拉伸到右边缘,您应该将 ul 项设置为 display: table;width:100%;。而 li 项应该是 display:table-cell;

.nav-wizard  {
    display: table; 
    width: 100%; 
}

.nav-wizard > li {
    display:table-cell;
    text-align: left;
}

看到一个updated fiddle