Scottie
Scottie

Reputation: 11308

Firefox float bug? How do I get my float:right on the same line?

I have the following fiddle:

http://jsfiddle.net/q05n5v4c/2/

In Chrome, it renders just fine. The chevron is on the right side.

However, in Firefox, it drops the Chevron down 1 line.

I've searched google and found several posts about this bug, but none of the suggestions have helped.

Any CSS experts out there that can tell me what I'm doing wrong?

Html:

<div class="btn-group">
    <button data-toggle="dropdown" 
            class="btn btn-default dropdown-toggle" 
            style="width: 400px;text-align: left;">

        Checked option 

        <span class="glyphicon glyphicon-chevron-down" 
              style='float: right;'></span>
    </button>
</div>

Upvotes: 54

Views: 20973

Answers (5)

Siew Ching Lee
Siew Ching Lee

Reputation: 239

Remove the float on the span, add position: absolute to it and position it using top/right/bottom/left.
Note: .btn-group already have position: relative from bootstrap.

HTML

<div class="btn-group">
  <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" style="width: 400px;text-align: left;">        
    <span class="glyphicon glyphicon-chevron-down"></span>
    Checked option
  </button>
</div>

CSS

div.btn-group span {
  position: absolute;
  top: 7px;
  right: 12px;
}

Here's a working fiddle.

Upvotes: -1

scooterlord
scooterlord

Reputation: 15339

Change the order of the float, put it before the text like this:

<div class="btn-group">
  <button data-toggle="dropdown" class="btn btn-default dropdown-toggle"style="width: 400px;text-align: left;">        
    <span class="glyphicon glyphicon-chevron-down" style='float: right;'></span>
    Checked option
  </button>
</div>

http://jsfiddle.net/q05n5v4c/3/

Upvotes: 102

Michael Petito
Michael Petito

Reputation: 13161

If you don't wish to reverse the order of your elements, you could float: left; the first element.

Upvotes: 4

DaniP
DaniP

Reputation: 38252

It seems like the property white-space is the cause of the issue. With the class btn this property is:

white-space:nowrap

If you change that property works fine:

.btn {
    white-space:normal
}

Check the Demo Fiddle

Upvotes: 64

Munshi Azhar
Munshi Azhar

Reputation: 317

Here is one more solution:

give style your span tag like this.

position:absolute;
right: 5px;
top : 9px

Upvotes: -2

Related Questions