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

前端 未结 5 808
深忆病人
深忆病人 2021-02-01 00:41

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

相关标签:
5条回答
  • 2021-02-01 01:22

    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/

    0 讨论(0)
  • 2021-02-01 01:28

    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.

    0 讨论(0)
  • 2021-02-01 01:33

    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

    0 讨论(0)
  • 2021-02-01 01:40

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

    0 讨论(0)
  • 2021-02-01 01:42

    Here is one more solution:

    give style your span tag like this.

    position:absolute;
    right: 5px;
    top : 9px
    
    0 讨论(0)
提交回复
热议问题