Reply
inline-divs working in IE but not Firefox
Old 03-19-2007, 02:29 AM inline-divs working in IE but not Firefox
Novice Talker

Posts: 7
Name: Evan Cobb
I've got a group of four DIV's I'm using as a horizontal navigation area. Ideally, it would look like 4 rectangles, one to the right of the one before it.

I'm using the following CSS for the DIVs:

Code:
#nav    {
  width: 200px;
  display: inline;
  border: 1px solid #ff0000;
  margin-top: 7px;
  margin-bottom: 7px;
}
The HTML implementation looks like this:

HTML Code:
<div id="nav">Home<br><img src="img/nav1.jpg">
</div>

<div id="nav">Gallery<br><img src="img/nav2.jpg">
</div>

<div id="nav">About<br><img src="img/nav3.jpg">
</div>

<div id="nav">Contact<br><img src="img/nav4.jpg">
</div>
In IE, it looks like I'd like it to. I'm still tweaking the CSS, but the basic idea is there. It looks like this:



But it breaks in Firefox when the pictures are added, looking like this:




Any suggestions on how to make this look universal between the two apps, and any hints towards a better, more standard code would be nice. This'll be the first site I've used DIV's in.

Thanks much in advance!
icbat is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-19-2007, 05:08 AM Re: inline-divs working in IE but not Firefox
King Spam Talker

Posts: 1,004
Location: Manchester, UK
Your navigation links are better represented as list items. Here is a good tutorial that explains how to create a list based menu.

Note that id's are used to uniquely identify an element but you have multiple div's with the same id. You should use classes instead, but that's by the by if you follow that tutorial
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 03-19-2007, 07:32 AM Re: inline-divs working in IE but not Firefox
chrishirst's Avatar
Super Moderator

Posts: 13,590
Location: Blackpool. UK
Or float the divs rather than setting the display to inline.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-19-2007, 03:07 PM Re: inline-divs working in IE but not Firefox
Novice Talker

Posts: 7
Name: Evan Cobb
The list idea is all fine and good; however, I tried that originally, with the same problem. As soon as the picture enters the element, the successive list moves with it. For instance, when you add pictures, it would be like this:

LINK1
[picture1]LINK2
[picture2]LINK3

etc., when the look I'm trying for is:

Link1 Link2 Link3
[pic1] [pic2] [pic3]

Is there a way to set the picture beneath the text, like I'm aiming to?
icbat is offline
Reply With Quote
View Public Profile
 
Old 03-19-2007, 03:28 PM Re: inline-divs working in IE but not Firefox
King Spam Talker

Posts: 1,004
Location: Manchester, UK
Have you tried assigning a background-image to your <li>s? Something like:
HTML Code:
li {
background: #fff url(pic.gif) no-repeat 5px 5px;
}
You can use the pixel measurements (left and top) to position the pic where you want, and you would have to manipulate with the padding on the <li>s to see it.
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 03-19-2007, 03:59 PM Re: inline-divs working in IE but not Firefox
Novice Talker

Posts: 7
Name: Evan Cobb
Alright, I've got it working now.

I did it with chrishirst's advice to try floating the div's, though to get them aligned with the rest of the document I put all of them inside of another div container, and played with margins and paddings til it was right.

Here's the final code:

Code:
#navcontainer    {
  width: 800px;
  margin: 0;
  padding: 0;
  background-color: #555;
}

html>body #navcontainer div a {
        width: auto;
        }

div.nav    {
  width: 190px;
  margin-top: 7px;
  margin-bottom: 7px;
  margin-left: 6px;
  float: left;
  background-color: #555;
  border: 1px solid #777;
  font-weight: bold;
}
HTML Code:
<div id="navcontainer">

<a href="#"><div class="nav">
Home<br><img src="img/nav1.jpg">
</div></a>

<a href="#"><div class="nav">
Gallery<br><img src="img/nav2.jpg">
</div></a>

<a href="#"><div class="nav">
About<br><img src="img/nav3.jpg">
</div></a>

<a href="#"><div class="nav">
Contact<br><img src="img/nav4.jpg">
</div></a>

</div>

And it looks like this:



Thanks, guys!
icbat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to inline-divs working in IE but not Firefox
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.20352 seconds with 12 queries