csstwitter-bootstrap-3twitter-bootstrap-wizard

Bootstrap 3 form-horizontal not working with bootstrapWizard


Pardon me, this might be silly question.

I'm trying to mix bootstrap 3 with twitter bootstrap wizard in Meteor:

<template name="bootstrapWizard">
    <div id="rootwizard" class="tabbable tabs-left col-sm-6">
        <ul>
            <li><a href="#tab1" data-toggle="tab">First</a></li>
            <li><a href="#tab2" data-toggle="tab">Second</a></li>
            <li><a href="#tab3" data-toggle="tab">Third</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane" id="tab1">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="control-label col-sm-2" for="email">Email:</label>
                        <div class="col-sm-4">
                            <input type="email" class="form-control" id="email" placeholder="Enter email">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-2" for="pwd">Password:</label>
                        <div class="col-sm-4">
                            <input type="password" class="form-control" id="pwd" placeholder="Enter password">
                        </div>
                    </div>                  
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-default">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="tab-pane" id="tab2">
                2
            </div>
            <div class="tab-pane" id="tab3">
                3
            </div>
            <ul class="pager wizard">
                <li class="previous first" style="display:none;"><a href="#">First</a></li>
                <li class="previous"><a href="#">Previous</a></li>
                <li class="next last" style="display:none;"><a href="#">Last</a></li>
                <li class="next"><a href="#">Next</a></li>
            </ul>
        </div>
    </div>
</template>

The column (or grid (?)) doesn't work well. If I take class="form-horizontal" out, the rows does get closer, but not how it should be.

I'm really new to this CSS and bootstrap stuffs, but I've wandered on stackoverflow for a couple of minutes and couldn't find similar cases.

Wondering if there's any bootstrap CSS class i should've used...

*Reference: bootstrap wizard and twbs:bootstrap 3.3.5

Edit: Current looks: enter image description here

Expected: enter image description here


Solution

  • As left aligned tabs no longer exist in Bootstrap 3, so you need to use stacked pills instead. Then you need to do a bit of tweaking of stacked Bootstrap pills to make them look more like the tabs you want:

    $(document).ready(function() {
      	$('#rootwizard').bootstrapWizard({'tabClass': 'nav nav-pills nav-stacked'});
    });
    /* Just for this snippet to push down the content - can be removed */
    #rootwizard {
        margin-top: 10px;
    }
    /* Consistent styling of the label on horizontal form */
    .control-label {
        padding-top: 7px;
        margin-bottom: 0;
        text-align: left;
    }
    
    /* Tweaking Bootstrap pills to look more like tabs when on the left */
    .nav-stacked.nav-pills>li.active>a, .nav-stacked.nav-pills>li.active>a:focus, .nav-stacked.nav-pills>li.active>a:hover {
        color: #555;
        background-color: #fff;
        border: 1px solid #ddd;
        border-right-color: transparent;
    }
    .nav-stacked.nav-pills>li>a {
        border-radius: 4px 0 0 4px;
    }
    .nav-stacked.nav-pills>li>a {
        margin-right: -1px;
    }
    .nav-stacked.nav-pills {
        border-right: 1px solid #ddd;
        padding-right: 0;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="http://vadimg.com/twitter-bootstrap-wizard-example/jquery.bootstrap.wizard.js"></script>
    <div class="container">
       <div id="rootwizard" class="tabbable tabs-left col-xs-12">
            <ul class="nav nav-pills nav-stacked col-xs-2">
                <li><a href="#tab1" data-toggle="pill">First</a></li>
                <li><a href="#tab2" data-toggle="pill">Second</a></li>
                <li><a href="#tab3" data-toggle="pill">Third</a></li>
            </ul>
            <div class="tab-content col-xs-10">
                <div class="tab-pane" id="tab1">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="control-label col-xs-2" for="email">Email:</label>
                            <div class="col-xs-offset-1 col-xs-8">
                                <input type="email" class="form-control" id="email" placeholder="Enter email">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-xs-2" for="pwd">Password:</label>
                            <div class="col-xs-offset-1 col-xs-8">
                                <input type="password" class="form-control" id="pwd" placeholder="Enter password">
                            </div>
                        </div>                  
                        <div class="form-group">
                            <div class="col-xs-offset-3 col-xs-8">
                                <button type="submit" class="btn btn-default">Submit</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="tab-pane" id="tab2">
                    2
                </div>
                <div class="tab-pane" id="tab3">
                    3
                </div>
                <div class="col-xs-11">
                    <ul class="pager wizard">
                        <li class="previous first" style="display:none;"><a href="#">First</a></li>
                        <li class="previous"><a href="#">Previous</a></li>
                        <li class="next last" style="display:none;"><a href="#">Last</a></li>
                        <li class="next"><a href="#">Next</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>