float problem in Firefox

S

squareboy

The simple HTML & CSS below uses float:left and float:right to display
the three <li>'s on the same line. This works on IE, and it also works
on Firefox if there is no <a href> tag inside the <li>. But Firefox
puts the "should be on the same line" link on the following line. Any
advice on how to get it to stay on the same line?

TIA


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css" media="screen">@import "style.css";</style>
</head>
<body>
<ul class="header">
<li>first</li>
<li>second</li>
<li class="sitelink"><a href="http://www.abc.com/">should be on same
line</a></li>
</ul>
</body>
</html>

style.css:

..header li {
float:left;
}
..header a {
float:left;
display:block;
}
..header .sitelink {
float:right;
}
..header .sitelink a {
float:right;
}
 
D

dorayme

"squareboy said:
The simple HTML & CSS below uses float:left and float:right to display
the three <li>'s on the same line. This works on IE, and it also works
on Firefox if there is no <a href> tag inside the <li>. But Firefox
puts the "should be on the same line" link on the following line. Any
advice on how to get it to stay on the same line?

TIA
style.css:

.header li {
float:left;
}
.header a {
float:left;
display:block;
}
.header .sitelink {
float:right;
}
.header .sitelink a {
float:right;
}

Get rid of all your css on this and replace with

..header li {
display:inline;
}

add margins and padding appropriately. You are getting too fancy.
 
S

squareboy

dorayme said:
Get rid of all your css on this and replace with
...
add margins and padding appropriately. You are getting too fancy.

It would be too fancy if this was all I was trying to achieve, but the
code I'm giving here is massively simplified to leave just the
underlying problem: that the link appears on the following line in
Firefox.

Interested to see if anyone actually knows how to fix this.

Cheers
 
D

dorayme

"squareboy said:
It would be too fancy if this was all I was trying to achieve, but the
code I'm giving here is massively simplified to leave just the
underlying problem: that the link appears on the following line in
Firefox.

Interested to see if anyone actually knows how to fix this.

Cheers

Fair enough... you sure that the nav bar cannot be an isolated
bit of code along the lines I suggest, easier to manage than the
float... but good luck...
 
N

Neredbojias

The simple HTML & CSS below uses float:left and float:right to display
the three <li>'s on the same line. This works on IE, and it also works
on Firefox if there is no <a href> tag inside the <li>. But Firefox
puts the "should be on the same line" link on the following line. Any
advice on how to get it to stay on the same line?

TIA

Delete both css entries for the "a"s.
 
A

Andy Dingley

squareboy said:
It would be too fancy if this was all I was trying to achieve, but the
code I'm giving here is massively simplified to leave just the
underlying problem:

That's why we don't usually respond to posted code, only to URLs.



You're trying to mix and match display: block and display: inline.
Either make your block eleemnts behave as inline, or else stop trying
to make an <a> behave in a block-like manner (floats, width etc.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top