Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the floated span drop?

Tags:

html

css

firefox

This code will work fine in Webkit (chrome) but not in firefox, where the second span will drop, do you know why?

<div id="sbar">
    <span id="status">Some Text</span>
    <span id="mlog" style="float: right;">Some text in the right</span>
</div>
like image 938
Vasco Fernandes Avatar asked Jan 24 '23 19:01

Vasco Fernandes


2 Answers

Try reversing the two spans.

<div id="sbar">
    <span id="mlog" style="float: right;">Some text in the right</span>
    <span id="status">Some Text</span>
</div>
like image 50
jonnii Avatar answered Jan 31 '23 19:01

jonnii


Yeah... reversing makes it work cause with floats, you need to arrange your elements like a stack that the browser can pick up -

so when floating left

A

B

C

will float to ABC -

A

AB

ABC

when all floated right will give you CBA, as in

A

BA

CBA

I've seen this implemented in firefox, haven't checked webkit. You can be safe with this, though.

like image 25
Sudhir Jonathan Avatar answered Jan 31 '23 18:01

Sudhir Jonathan