When working with div's and span's in Expression Web, nearly all current browsers work fine, EXCEPT Firefox 2.0, which completely destroys the layout, as if everything were a block element (there's a carriage return after every object). Inline elements aren't kept that way.

This is a sample of the code, with image and div id's changed (it looks a bit convoluted, but it makes sense to be, and it works in most browsers):

CSS:

body {
	text-align: center;
}
.BlockContainer {
	display: block;
	margin: 2px;
}
.InlineBlockContainer {
	display: inline-block;
	vertical-align: top;
}
#Section1 {
	position: absolute;
	visibility: visible;
	margin: 0 auto;  <!-- this is not needed for any browser, but most people say it's a "best practise" for FF, even though it still doesn't work for me in FF2 -->
	width: 100%;
	left:0%;  <!-- this, along with the width:100% will center a div easily -->

HTML:
<body>
<div id="Section1">
   <span id="SubSection1">   <!-- there is no CSS for this object yet, but there will be -->
      <span class="InlineBlockContainer" >
         <span class="BlockContainer">
            <img src="images/object1img.jpg" alt="Object1" />
         </span>
         <span class="BlockContainer">
            <img src="images/object1logo.jpg" alt="Object1Logo" />
         </span>
      </span>
      <span class="InlineBlockContainer">
         <span class="BlockContainer">
            <img src="images/object2img.jpg" alt="Object2" />
         </span>
         <span class="BlockContainer">
            <img src="images/object2logo.jpg" alt="Object2Logo" />
         </span>
      </span>
   </span>
   <span id="SubSection2">   <!-- similar to #Subsection1 -->
.
.
.
   </span>
</div></body>

So what this gives me is a row of subsection "boxes" (i know that's not the code term, but i'm using it here for simplicity sake) that are side-by-side, inside each subsection box is 2 further sub-section boxes, also side-by-side. Then, inside each of those boxes are 2 images, which need to be one on top of the other. It took me awhile to figure out which CSS options to use, but this does work in all the mentioned browsers, EXCEPT FF2, and I'm not supporting legacy browsers like FF1.x, IE6, NS-anything, etc. I'm having enough trouble as it is with "current" browsers (FF2) than have to worry about backwards compatibility. Quite frankly, if Safari 3 and Opera 9 are supposed to be as standards-compliant as they say they are, then I don't know how Firefox 2 can really by touting the same, considering that both Safari 3 and Opera 9 render identically to IE7.

So how do I go about fixing this? It would seem that this is either an absolute positioning bug in FF2, or FF2 just isn't respecting normal flow for block and inline[-block] objects....

Ok, another problem:

Firefox 3b5 gets the layout right, but it has problems with javascript code for the onclick property.

This is a sample of the javascript code for the onclick property of an img tag:

onclick="javascript:document.getElementById('Logo1').setAttribute('src','images/logo1bold.jpg');document.getElementById('Logo2').setAttribute('src','images/logo2.jpg');document.getElementById('Section1').style.visibility='visible';document.getElementById('Section2').style.visibility='hidden';"

Basically what should happen is that when someone clicks on the Logo1 image, it should show the "bold" version (it's text, rendered as an image), should set the Logo2 image as plain, and should show the Section1 layer, while hiding the Section2 layer.

Now I know that in the supported browsers (IE7/8, Opera9, Safari3), I can also use the abbreviation for the style property, so instead of using

document.getElementById('[I]id[/I]').style.visibility

, I can shorten it to just

[I]id[/I].style.visibility

, but either option works.

It just doesn't work at all in either Firefox 2 or 3b5, either way I write it. At this point, it looks like it's just the javascript stuff, and not CSS support in FF, since the underlying layer doesn't show through the spaces in the top layer. So how is my syntax flawed in such a way that FF doesn't support it?

Just out of curiosity, is there a way to similarly shorten the .setAttribute part? It doesn't seem to let me shorten the object down to just the id. It would seem that it requires the top level DOM object classifications, unlike the .style part....

Recommended Answers

All 11 Replies

IS there not a page for us to quickly look at?
Would help us if we could "see" it in different browsers.

Further, in most cases, what works in "most vbrowsers2 should work in others with a few tweaks.
Some times it's a browser misinterpreting... but more often it boils down to either a minor oversite or misconception of browser behaviours to certain css renderings in a browser.

I'm looking at hte CSS... and suffering confusion.
Why are you definign the visibility... by default it's visible.
You are setting an auto margin ... and 100% width???
inline-block is generally only used by IE(6) that I know off (and then often only to handle some of thebugs or to equate to some of the table styles supportted by other browsers).
I'm also not understanding the reason for tha absolute positioning.

(Again, being able to see it would help a great deal!)

As to not supporting "legacy"... You do realise how many people you may be missing out? Can you (or the end client) affort to miss out on that percentage of potential clients/customers/end users?

I've been working on this page a bit. Taking options out, or modifying them. I haven't tested the new changes in other browsers, but it still works in IE7 and 8. If I broke something on other browsers, let me know, but I doubt anything I did would've changed Firefox compatibility.

IS there not a page for us to quickly look at?

yes: http://tinyurl.com/6fb47l

I'm looking at hte CSS... and suffering confusion.

It'll be clearer when you see it. I may have used additional block definitions that aren't needed for normal flow, but it just seemed simpler to specify them all so that I can find what I'm looking for without ID'ing every sub-object (which wasn't necessary).

Why are you definign the visibility... by default it's visible.

Because they are "pop-over" layers. You'll see what I mean. There is also a popup div when you click on the first image. The rest aren't complete.

You are setting an auto margin ... and 100% width???

As I mentioned, I added that later to test if Firefox would accept it, since it doesn't correctly lay it out as it is, and it's seems to be a recommended best practise for Firefox, when using centered div's. It is completely unnecessary for other browsers.

I'm also not understanding the reason for tha absolute positioning.

Again, it might be clearer when you look at it. The absolute positioning works to absolutely position inside a relative positioned object. When the option is taken out, it's more of a layout disaster than what Firefox renders.

As to not supporting "legacy"... You do realise how many people you may be missing out? Can you (or the end client) affort to miss out on that percentage of potential clients/customers/end users?

It's for a computer store page, so getting people to get something new, supported, and up-to-date is kind of the point. I also want to make sure it's XHTML 1.1 compliant which means dealing with backwards compatibility will likely not make that possible. I'd rather have a redirect page to support info than deal with multiple versions of the same page.

BTW: does anybody know how to get around the W3 validator XHTML warning for MIME types for a site hosted in IIS 6? If I change the filename and follow instructions online to change the default page load on IIS, it usually just comes up with a "download file" dialog box on most browsers....Is that anything I should even bother worrying about?

Okay... we're obviously at different ends of the "user" spectrum.

Yes... I can see your point about getting people to "upgrade"... but if they are upgrading, it's because they have the old stuff.... right?


More importantly,. there are some pretty big accessibility issues with that site.
No tabbing/keyboard navigation (you code isn't using links).
The popup I get on click is also a big no-no, as you cannot tab to anythign to close it or go back.

Sorry, but you really might want to rethink.
What you are wanting to achieve should be doable, using more "standard" approaches that every one can use.
(You may also find that you get alot more SEO Milage for other methods!).


Will go and have a play and see what alternative I can kick up.
Sure I've done simialr before, so I'll hunt through my notes.

Okay... not exactly a match... but a damn site cleaner/leaner/accessible...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<title>PC Components Canada</title>
<link rel="stylesheet" type="text/css" href="http://www.pccomponentscanada.com/css/stylesheet.css" />
<style type="text/css">
.style1 {
	left: 0%;
	top: 15px;
}

.itemdisplayblock
{float: left; margin: 0 auto; border: 1px solid red; text-align: center;}

.itemouter
{float: left; margin: 0 2px; padding: 3px; #display: inline; border-top: 5px double #ffffff; height: 135px;}
.itemouter:active, .itemouter:hover, .itemouter:focus
{border-top: 5px double #000000;}


.itemimage, .itemlogo
{border:none;}

.itemlogo
{float: left; clear: left;}
</style>
</head>

<body>

<div>
	<img src="http://www.pccomponentscanada.com/images/pccclogo.jpg" alt="PC Components Canada" width="150" height="150" /></div>
<div>
	<span class="InlineBlockContainer">
	<img src="http://www.pccomponentscanada.com/images/desktopsbold.jpg" alt="Desktops" id="DesktopLogo" onclick="javascript:document.getElementById('DesktopLogo').setAttribute('src','http://www.pccomponentscanada.com/images/desktopsbold.jpg');document.getElementById('NotebookLogo').setAttribute('src','http://www.pccomponentscanada.com/images/notebooks.jpg');Desktops.style.visibility='visible';Notebooks.style.visibility='hidden';" width="100" height="25" /></span>
	<span class="InlineBlockContainer">
	<img src="http://www.pccomponentscanada.com/images/notebooks.jpg" alt="Desktops" id="NotebookLogo" onclick="javascript:document.getElementById('DesktopLogo').setAttribute('src','http://www.pccomponentscanada.com/images/desktops.jpg');document.getElementById('NotebookLogo').setAttribute('src','http://www.pccomponentscanada.com/images/notebooksbold.jpg');Desktops.style.visibility='hidden';Notebooks.style.visibility='visible';" width="100" height="25" /></span>
</div>

<hr />

<div id="itemdisplayblock">

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/spark.jpg" alt="Spark" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/spark.jpg" alt="Spark" width="82" height="34" />
</a>

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/origin.jpg" alt="Origin" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/origin.jpg" alt="Origin" width="83" height="34" />
</a>

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/proplaya.jpg" alt="Pro Playa" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/proplaya.jpg" alt="Pro Playa" width="154" height="47" />
</a>

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/omnificent.jpg" alt="Omnificent" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/omnificent.jpg" alt="Omnificent" width="182" height="31" />
</a>

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/opus.jpg" alt="Opus" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/opus.jpg" alt="Opus" width="78" height="34" />
</a>

<a class="itemouter" href="#" title="blah">
	<img class="itemimage" src="http://www.pccomponentscanada.com/images/products/systems/desktops/thumbs/symphony.jpg" alt="Symphony" width="80" height="80" />
	<img class="itemlogo" src="http://www.pccomponentscanada.com/images/products/systems/desktops/logos/thumbs/symphony.jpg" alt="Symphony" width="156" height="34" />
</a>

</div>


</body>

</html>

With a little thought (possibly juggling some of your earlier code), it may be possible to "centralise".
To do that though, you may need to sets of styling... one using inline-block, the other using table-row/table-cell etc. (for mff).

Hope that helps.

The biggest problem is with Firefox 2.0 not supporting the standard "inline-block" style attribute. This is NOT an IE-specific attribute either, it is just another instance of one software developer (Mozilla) criticizing another for not following web standards (Microsoft) when they themselves don't practise what they preach. It's no wonder Expression Web actually supports the option under CSS 2.1 and XHTML 1.1 mode - it IS part of the standard. As for the Javascript part, I've come up with another solution that works. Although the Javascript itself hasn't changed really all that much (I went out of my way to drill right down the the top-level DOM references), this method does work, because I'm no longer using several nested div's and span's for the main images. Instead, I re-did the images as combined thumbnails and logos instead of keeping them separate and requiring a more complicated layout. Now Firefox 2.0 renders them in normal flow properly. I've tried Safari3 and it seems to be fine also. I haven't had the chance to try Firefox 3b5 or Opera9 because Virtual PC tends to BSOD my machine with a STOP 0A when I have many apps open. It's the only program that does. Dunno why it happens, but it just does. Day to day operations in my standard host OS never show any problems, but that discussion is for a different site. I use Virtual PC because I don't want to gum up my main production OS, which is also used for business stuff too. Safari is one of the main reasons for that decision. Apple software is just junk.

Oh and BTW: I'm using XHTML 1.1 for several reasons - to support newer browsers, and to keep the code as clean as possible, so as to get the browser to do the work with as little instruction as possible. Supporting old browsers that don't support XHTML properly (Firefox 1.0 & IE6 come to mind), is going to be hindered by going this route, but anyone not using at least IE7 and Firefox 1.5 shouldn't be on the internet what with the security flaws the way they are. Both browser versions are several years old now (IE6 was even released BEFORE Windows XP!). Being that this is for a computer store business, it's a bit of "tough love" through security restrictions to garner people to upgrade. That's why I already have plans to discontinue support for those old browsers with a redirect link to a support page with a message explaning the reasoning for this. This may sound like a harsh decision but this is for a business website after all.

Well, best of luck.

If you are not the store owner, and not apprised them of the alterations and limitations of what you are implementing, you could be leaving them open to legal action as well as causing a loss of certain user-groups and potential clients.

The <!-- --> comments are not valid inside the style tags. You can't use them to comment styles. Stylesheet comments are enclosed with /* */ delimeters.

The <!-- --> comments are not valid inside the style tags. You can't use them to comment styles. Stylesheet comments are enclosed with /* */ delimeters.

If you're referring to stuff above, they are just samples and not actual code.

Well after looking at the site In different browsers I say scratch that idea and make a new one. Swap images could be used in the same way and with more compatability. Also I tried it in Safari, Firefox, and Internet Explorer and it only worked in IE and it didn't even work that well.

Well after looking at the site In different browsers I say scratch that idea and make a new one. Swap images could be used in the same way and with more compatability. Also I tried it in Safari, Firefox, and Internet Explorer and it only worked in IE and it didn't even work that well.

I've worked on it several times since the original post. It's on the back burner now until I get more time to work on it.

Ah Ok Then. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.