如何将向导与左右两侧对齐?

时间:2015-04-24 12:22:04

标签: css twitter-bootstrap twitter-bootstrap-3

简而言之,这是我的current code,我希望它看起来像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的右侧对齐。我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

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

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

<强> JSFiddle Demo

答案 1 :(得分:0)

如果您希望它伸展到右边缘,您应该制作 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Model; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import weka.core.Instances; import weka.core.converters.ArffSaver; import weka.core.converters.CSVLoader; /** * * @author sanketh */ public class testClass { public void createArff(String Filename) { try { String path = Filename.substring(0, Filename.length() - 3); System.out.println("new path:" + path); String[] args = new String[2]; args[0] = path + "csv"; args[1] = path + "arff"; // load CSV CSVLoader loader = new CSVLoader(); loader.setSource(new File(args[0])); Instances data = loader.getDataSet(); System.out.println(data); // save ARFF ArffSaver saver = new ArffSaver(); saver.setInstances(data); //saver.setFile(new File(args[1])); saver.setFile(new File("h:\\abc.arff")); saver.writeBatch(); } catch (IOException ex) { //System.out.println("Please try with some other test data!"); // attribMap.resultLog="Please try with some other test data!"; Logger.getLogger(GenerateFile.class.getName()).log(Level.SEVERE, null, ex); } } public static void main(String[] args) throws Exception { String nepath="H:\\file.csv"; testClass t1=new testClass(); t1.createArff(nepath); } } 项目 Exception in thread "main" java.lang.NullPointerException at java.io.Writer.<init>(Unknown Source) at java.io.PrintWriter.<init>(Unknown Source) at java.io.PrintWriter.<init>(Unknown Source) at weka.core.converters.ArffSaver.writeBatch(ArffSaver.java:187) at Model.testClass.createArff(testClass.java:39) at Model.testClass.main(testClass.java:65) /* * If 'main' is defined we clear that definition * to get our default 'main' function back. */ #ifdef main # undef main #endif /* main */ int main(int argc, char** argv) { // ... return 0; } 。虽然ul项应为display: table;

width:100%;

查看 updated fiddle