Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent break in div with float right? (bootstrap)

I have the following HTML. And the text (tidbit) on the right keeps dropping off to the next line. This is in chrome. Is there a way to keep what is inside of the pull-right div together in one line? here is the jsFiddle.

<div class="container" style="width:500px;>
    <div class="controls controls-row">
        <span class="add-on">This can be quite long</span>
        <div class="pull-right">
            <input class="input-mini" name="Amount" type="number" />
            <button type="button" class="btn" style="margin-bottom: 10px">Add</button>
            <div style="text-align:right; width:40px;">tidbit</div>
        </div>
    </div>
</diV>
like image 361
Arturo Hernandez Avatar asked May 26 '13 18:05

Arturo Hernandez


1 Answers

You can do this with two corrections:

  1. Set display: inline-block in the "tidbit" div.
  2. Set white-space: nowrap to the pull-right container.

 

<div class="container" style="width:500px;>
            <div class="controls controls-row">
            <span class="add-on">This can be quite long</span>
            <div class="pull-right">
                <input class="input-mini" name="Amount" type="number" />
                <button type="button" class="btn" style="margin-bottom: 10px">Add</button>
                <div style="text-align:right; width:40px; display: inline-block;">tidbit</div>
            </div>
        </div>
</diV>

 

.pull-right{
    white-space:nowrap;
}

Example Fiddle

like image 72
Sirko Avatar answered Sep 29 '22 08:09

Sirko