39

I've tried all the example code out there, but for some reason I can't do the following:

+-------------------------------------------------------------------------------+
|               |                                        Login  [ search   ]    |
|  SITE LOGO    |---------------------------------------------------------------+
|               |                      Page 1  |  Page 2 |  Page 3 |  Page 4    |
+-------------------------------------------------------------------------------+

I am feeling like there's no way to make this work. Am I trying to this in vain?

ATL_DEV
  • 9,256
  • 11
  • 60
  • 102

2 Answers2

56

It's possible, but I think you're really pushing the limits/purpose of TBS. Using your own markup could greatly simplify the DIV-soup that is required to make this work in TBS.

UPDATE: See below for replications of this solution that I've made using Twitter Bootstrap 3. The original question and answer were for Bootstrap 2.

Fiddle Example

<div class="container">
    <div class="navbar">
        <div class="navbar-inner">

            <img src="http://placehold.it/70x70" class="span1" style="position:relative;top:10px">

            <div class="span10">
                <div class="row">
                    <div class="span2 offset5" style="text-align:right">
                        <div class="navbar-text">
                            <p><a href="#">Login</a></p>
                        </div>
                    </div>
                    <div class="span2 offset1">
                        <div class="pull-right">
                            <form class="navbar-form">
                                <div class="input-append">
                                    <input class="span2" id="appendedInputButtons" type="text">
                                    <button class="btn" type="button">Search</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="span10">
                        <ul class="nav pull-right">
                            <li><a href="#">Page 1</a></li>
                            <li class="divider-vertical"></li>
                            <li><a href="#">Page 2</a></li>
                            <li class="divider-vertical"></li>
                            <li><a href="#">Page 3</a></li>
                            <li class="divider-vertical"></li>
                            <li><a href="#">Page 4</a></li>
                        </ul>               
                    </div>
                </div>

            </div>

        </div>
    </div>
</div>

TWITTER BOOTSTRAP 3 UPDATES:

The markup for TBS3's navbar changed slighty, as did their scaffolding. Here are two replications of the my original solution, one that matches the original exactly and a variation.

Exact Replication http://jsfiddle.net/technotarek/t67Ms/

Replication with Full Width Navbar http://jsfiddle.net/technotarek/HxvLS/

(Hint, you can adjust the second replication so that all of the internal elements span the entire navbar by removing the div.container element that follows immediately after the nav tag.)

technoTarek
  • 3,218
  • 2
  • 21
  • 25
  • For the Fiddle, make sure to expand the result window to at least 940px wide. – technoTarek Nov 14 '12 at 03:46
  • Wow! Gee! Thanks! I'm not worthy... This took many hours of experimentation and I couldn't get this to work. The biggest difference between my ill-fated implementation and yours is that you create the column and then the two rows inside of it. I did it backwards. I created two rows and then the columns inside of it. The problem with BPS and CSS in general is that the markup and CSS gets so confusing you tear it up and start all over again. Thanks again. I wish I could award you some extra points. – ATL_DEV Nov 15 '12 at 02:59
  • You make a good point about creating your own component, but you wind up recreating a lot of functionality and appearance you get for free if you use the standard implementation. I found the class names are used to identity elements in their JS implementation. It would have been nice if they used the data tags for this purpose. You, however, get a more semantic markup and no soupy, supinely or spiny DIVS. On the latest example page, they have a marketing site where they bypass the navbar entirely. – ATL_DEV Nov 15 '12 at 03:13
  • This is fantastic and I am also making use of it. Thank you. However, there is one tiny bug I spotted:
  • Page 4
  • The last
  • should be a closing tag, needs the "/".
  • – ThePerson Oct 26 '14 at 17:45
  • Does this example has the collapse facilities for small devices..? i am trying this one but doesn't collapse on small resolution like the default navbar does? do i have to make any change.? – Saif Jan 22 '15 at 11:29
  • @Saif I excluded that from my examples, but you should be able to re-incorporate it pretty easily. – technoTarek Jan 22 '15 at 16:21
  • yah i got it now, just needed a clarification before integrate in my project. Thanks for the response. – Saif Jan 22 '15 at 16:38
  • How about if you want the navbar to be collapsable? – Marcel Gruber Nov 24 '15 at 00:20