471,873 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Images breaking nested div layout in firefox (works fine in IE)

8
first of all, hello (first time poster).

the url in question: http://www.type3studios.com/?projects

(i guess you can grab the html and css from there, but if you want, i'll post it.)

EDIT: if you do grab my css and html, you're mainly looking for the .block, .blocka, and .blockb sections.

on that site, i'm using the "unordered list of divs with display:table-row and display:table-cell" trick to set up several rows of 3 boxes each. they work fine without images as shown below.

(in case this url changes, i'm including some pictures to help explain)



that is in firefox. as you can see the layout fits within the page. note the areas with the text 'main screenshot' - that is the alt value for my images.

now... here is the same page with the images



i'm not sure what's causing this, but the <li> sections are becoming huge, and my .blocka and .blockb (which are within the <li>) are dropping below where they should be.

here is the same page with images in IE (this is how i want it to look in firefox). note however that in my html source, i specify different styling to use for IE, since display:table-row and display:table-cell don't work properly.

Aug 10 '07 #1
19 4004
drhowarddrfine
7,435 Expert 4TB
I'm walking out the door for the weekend but things you can check:
1) Validate your html for one error and CSS for four. There is no such thing as 'float:center'.
2) Check your divs for this IE bug. IE expands elements to contain floated and absolutely positioned elements. This is incorrect behavior but could be causing the problem.

Sorry I don't have time to do more.
Aug 10 '07 #2
vecima
8
thank you for your reply.

NOTE: the page in question has been moved to:
http://www.type3studios.com/test/?projects

the CSS now validates, but the HTML validation fails because i used a div with nothing in it, but with a background image for the main site "banner" image. (so i could easily switch out the image with the style switcher at the bottom). anyhow, i don't think that error is affecting this one.

while i thank you whole heartedly for your response, i'm not sure if you understood my original post... the page works fine in IE, but breaks in Firefox. That in and of itself seems backward ;-) most of the time working on updating this site it's been IE that's needed tweaks, but in this particular case it's the other way around.

anyhow, I'll keep tinkering and if you or anyone else has any ideas, be sure to let me know!
Aug 11 '07 #3
vecima
8
well, i seemed to have answered my own question.

i replaced the following CSS code:

Expand|Select|Wrap|Line Numbers
  1. .block ul {
  2.     display: table-row;
  3.     list-style: none;
  4.     margin: 0;
  5.     padding: 0;
  6.     border: none;
  7.  
  8.     height: 150px;
  9.     min-height: 150px;
  10.     max-height: 150px;
  11. }
  12.  
  13. .block li {
  14.     display: table-cell;
  15.     text-align: center;
  16.     margin: 0;
  17. }
with this:

Expand|Select|Wrap|Line Numbers
  1.     .block ul {
  2.         display:block;
  3.         float:left;
  4.         list-style: none;
  5.         margin: 0;
  6.         padding: 0;
  7.         border: none;
  8.     }
  9.  
  10.     .block li {
  11.         display:block;
  12.         float:left;
  13.         text-align: center;
  14.         margin:0;
  15.     }
the new code is what i was telling IE to do all along. I could of swore I tried it before, but when I tried it again, IE and firefox now display the same (in a good way this time! :-) )

thanks for your help, and i'm sure i'll be back to ask some more questions!
Aug 11 '07 #4
vecima
8
hello again. I've fixed the initial problem, but i'm having another, and since it's on the same page (here), and a similar situation, i figured i'd just use the same thread.
again, IE is displaying as i wish, and firefox is a bit off.

this first shot is from IE: (notice how the 'thumbnail' images fit within the row).



the next shot is from Firefox: (notice the space between the images, and how the bottom two overflow onto the gray bar beneath).



the css styling these images is here:
Expand|Select|Wrap|Line Numbers
  1. a:link img {
  2.     border: 2px solid #3d5e57;
  3. }
  4. a:visited img {
  5.     border: 2px solid #3d5e57;
  6. }
  7. a:hover img {
  8.     border: 2px solid #a6f5fa;
  9. }    
  10. a:active img {
  11.     border: 2px solid #a6f5fa;
  12. }
any ideas on how to make them both show the images closer together (like the IE rendering)?
Aug 14 '07 #5
drhowarddrfine
7,435 Expert 4TB
i'm not sure if you understood my original post... the page works fine in IE, but breaks in Firefox. That in and of itself seems backward ;-)
Yes it is backwards because you are trying to compare what IE is doing and implying Firefox is doing something wrong. However, even though IE is doing what you want, it isn't doing it correctly.

1) IE is in 'quirks mode', meaning it is using its "broken box model". The reason is that you have 'stuff' before the doctype. Remove all comments and spaces of any kind before the doctype to get IE out of quirks. Firefox, otoh, is not in quirks because it doesn't have this sort of problem.

2) The validator complains you have a misplaced <div>. This needs to be fixed.

Now, how those two items affect your page, I don't know because I can't fix the first one and don't have time right now to fix the second (just got back from out of town). But it is hard enough to debug valid code than try and mess with invalid code. This I think you already know.
Aug 14 '07 #6
vecima
8
thanks again for clarifying.

i've fixed the <div> situation, and moved my doctype declaration to the top of the page, and the validator declared it valid, however the validator told me about my mime type conflict (serving text/html rather than application/xhtml+xml). it also provided me a link from which i copied in the following php code:

(from http://juicystudio.com/article/content-negotiation.php)
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     header("Vary: Accept");
  3.     if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml")) 
  4.         header("Content-Type: application/xhtml+xml; charset=utf-8");
  5.     else
  6.         header("Content-Type: text/html; charset=utf-8");
  7. ?>
apparently this code needs to be at the top of the document, or else i get the folowing errors:

Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\xampp\Type3\index.php:3) in E:\xampp\htdocs\xampp\Type3\index.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\xampp\Type3\index.php:3) in E:\xampp\htdocs\xampp\Type3\index.php on line 6
if i do place the php code at the top, with the doctype immediately following, the site is rendered with a white border around it, and the validator still tells me about a mime type conflict anyway.


for the time being, i've deleted the php code, moved the doctype to the very top and used this meta tag:
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

i still get the warning about mime types, but the page does validate. if you think it's necessary i'll try further to allow the site to serve application/xhtml+xml, but currently i think many sites leave it as i have it now (correct me if i'm wrong).

now that all of that is out of the way, the site is still rendering exactly as it was in the images in my previous post. if IE is still rendering in 'quirks' mode, there must be something else causing it. notice in the firefox shot that the images run over onto the next gray bar beneath, which itself is enlarged for some reason. also notice that IE seems to use the same distancing between images vertically and horizontally, whereas firefox seems to use more distancing vertically between the images. this is what i want to 'correct' - i understand that it may not be 'wrong' but at any rate, i would like it to display in firefox as it is doing in IE.

i also noticed a problem with my style switching mechanism. the links are at the bottom of the page. it works fine in firefox, but in IE is a bit odd.

thanks again for your help.
Aug 15 '07 #7
TRScheel
638 Expert 512MB
You are coding HTML in a backwards manner... Code for firefox, fix for IE. Dont code for IE than fix for firefox because it will be a convulated mess.
Aug 15 '07 #8
vecima
8
i actually have been coding for firefox and fixing for IE.

in this particular case i tried something that i expected to work in firefox, and when it didn't, i checked it in IE, and by chance it looked as i expected it to. the fact that this happened twice in a row is to me as mind boggling as it is frustrating.
Aug 15 '07 #9
TRScheel
638 Expert 512MB
i actually have been coding for firefox and fixing for IE.

in this particular case i tried something that i expected to work in firefox, and when it didn't, i checked it in IE, and by chance it looked as i expected it to. the fact that this happened twice in a row is to me as mind boggling as it is frustrating.
I can imagine... I have a squishy ball next to my desktop machine for working on HTML for this very reason.

Did you try setting the margins/padding on the images? Have you read into a global reset CSS file (and no, not the * everything reset files).'

Page on Global Reset

DO NOT DO (or any variation of this):

Expand|Select|Wrap|Line Numbers
  1. /* CSS global reset for all browsers */ 
  2. * {
  3.     padding: 0;
  4.     margin: 0;
  5.    }
  6.  
Aug 15 '07 #10
drhowarddrfine
7,435 Expert 4TB
The reason for the mime error is your server is saying it is sending text/html in the HTTP header. Most people think that if they use the xhtml doctype that they are sending xhtml. Not true. This is why many suggest just using html and forget about xhtml. xhtml doesn't work in IE anyway (it's treated as html).

EDIT: You especially should NOT use xhtml ver 1.1. It is to be served as XML only! Change it back to 1.0 or, better yet, go to html 4.01.
Aug 15 '07 #11
TRScheel
638 Expert 512MB
xhtml doesn't work in IE anyway (it's treated as html).
Which is sad... I think I should write my own version of IE and sell it to them. I could get it up to standards faster.
Aug 15 '07 #12
drhowarddrfine
7,435 Expert 4TB
Which is sad... I think I should write my own version of IE and sell it to them. I could get it up to standards faster.
Technically, xhtml will work in IE if you serve it as XML but that opens a whole other can of worms. MS could make their browser standards compliant but that would work against their dominance philosophy. That's why JScript is not compatible with standard javascript, and MSXML is not compatible with standard XML, and they fight OpenDoc which isn't compatible with Word.

Standards are bad for Microsoft, so they think. It means they can't sell you something, so they have to kill everything else. They killed Netscape in the 90s. This is why the Justice Department and EU are suing them.
Aug 15 '07 #13
drhowarddrfine
7,435 Expert 4TB
You especially should NOT use xhtml ver 1.1. It is to be served as XML only! Change it back to 1.0 or, better yet, go to html 4.01.

No, IE is not in quirks now.
Aug 15 '07 #14
TRScheel
638 Expert 512MB
Technically, xhtml will work in IE if you serve it as XML but that opens a whole other can of worms. MS could make their browser standards compliant but that would work against their dominance philosophy. That's why JScript is not compatible with standard javascript, and MSXML is not compatible with standard XML, and they fight OpenDoc which isn't compatible with Word.

Standards are bad for Microsoft, so they think. It means they can't sell you something, so they have to kill everything else. They killed Netscape in the 90s. This is why the Justice Department and EU are suing them.
The state of Iowa had a class action lawsuit against microsoft a few months back and everyone who owned a microsoft product was given a pretty decent portion. I think it was like $30 per windows licence, $15 per office. Something similiar. Considering I had like 10 windows licences and like 5 office licences, I was pretty excited.

Edit: ALSO, I bought like 5 of those windows keys from the U and 2 of the office keys from the U, all 7 at like $10 a piece.
Aug 15 '07 #15
drhowarddrfine
7,435 Expert 4TB
now that all of that is out of the way, the site is still rendering exactly as it was in the images in my previous post.
That's OK. We just have to make sure no errors are fooling us.

min-width and max-width do not work in IE.
Neither does min-height or max-height.
Aug 15 '07 #16
drhowarddrfine
7,435 Expert 4TB
I'm wondering if min/max stuff is the problem. Search here for those properties. (Look there just to see how bad IE is, too)

Sorry, my help is on the fly. Getting geared up for a huge project next week.
Aug 15 '07 #17
vecima
8
as a cleanup measure, i've deleted all of the min and max height and width from my css.

you were absolutely right, it changed nothing.

as for the layout, i made a bit of progress, though i'm not sure why.

to bring the images closer together vertically, i simply inserted a <br /> after the first two images. that seems a little hacky to me, but it now looks exactly as i had wanted.

as for the images running into the gray bar: i took a look at my php code for this page:

Expand|Select|Wrap|Line Numbers
  1. <div id='innerpage'>
  2.     <strong>Projects</strong>
  3.  
  4.     <div class='thickbar'>
  5.         <strong>Games</strong>
  6.     </div>
  7.  
  8.     <div class='colorbar'>
  9.         <strong>Earth - Right</strong>
  10.     </div>
  11.  
  12.     <?php include "projects_er/er.php"; ?>
  13.  
  14.     <div class='thickbar'>
  15.         <strong>Mods</strong>
  16.     </div>
  17.  
  18.     <div class='colorbar'>
  19.         <strong>The Battle of Philadelphia</strong>
  20.     </div>
  21.  
  22.     <?php include "projects_bop/bop.php"; ?>
  23.  
  24.     <div class='colorbar'>
  25.         <strong>The Rebel</strong>
  26.     </div>
  27.  
  28.     <?php include "projects_rebel/rebel.php"; ?>
  29.  
  30.     <div class='thickbar'>
  31.         <strong>Maps</strong>
  32.     </div>
  33.  
  34. </div>
and i realized that the transition where this was happening was a special case, and might not be caused by the images at all. it's the only spot on the page where the colorbar (for "The Rebel") comes after an element other than a "thickbar". I used the same thumbnail links to test this theory, and it turns out i was right. They work fine everywhere else. I was tricked into thinking the images were breaking it because that one spot was the only one where i implemented the images. I decided to try inserting a "thickbar" above the colorbar in question, like so:


Expand|Select|Wrap|Line Numbers
  1. <div id='innerpage'>
  2.     <strong>Projects</strong>
  3.  
  4.     <div class='thickbar'>
  5.         <strong>Games</strong>
  6.     </div>
  7.  
  8.     <div class='colorbar'>
  9.         <strong>Earth - Right</strong>
  10.     </div>
  11.  
  12.     <?php include "projects_er/er.php"; ?>
  13.  
  14.     <div class='thickbar'>
  15.         <strong>Mods</strong>
  16.     </div>
  17.  
  18.     <div class='colorbar'>
  19.         <strong>The Battle of Philadelphia</strong>
  20.     </div>
  21.  
  22.     <?php include "projects_bop/bop.php"; ?>
  23.  
  24.     <div class='thickbar'>
  25.         <strong>Mods (this is a div class='thickbar')</strong>
  26.     </div>
  27.  
  28.     <div class='colorbar'>
  29.         <strong>The Rebel</strong>
  30.     </div>
  31.  
  32.     <?php include "projects_rebel/rebel.php"; ?>
  33.  
  34.     <div class='thickbar'>
  35.         <strong>Maps</strong>
  36.     </div>
  37.  
  38. </div>
and my result was that the page displayed exactly as i expected it to.

again, i'm not sure why this is happening this way, but maybe this will shine some light that one of you could help me see?

here is an example of the regular version: (notice how the images still slightly overlap the following gray bar, and how the gray bar is still bigger than the other ones)
http://www.type3studios.com/?projects

and here is an example with the extra .thickbar (it displays like it should, except i don't really want the extra .thickbar there)
http://type3studios.com/test/?projects

thanks yet again guys.

i'm almost afraid to start testing the page in safari ;-)
Aug 15 '07 #18
drhowarddrfine
7,435 Expert 4TB
Well, now you're back in quirks because of the comments on the first line. Also, you have defined id's more than once. An id is a unique name for one element on a page. If you need to apply the same style to multiple elements, use 'class'.

Safari will be fine. A lot better than IE will be.
Aug 15 '07 #19
vecima
8
Well, now you're back in quirks because of the comments on the first line...
i'm not sure what you mean... there are no comments on the first line. the code i posted is from the file projects.php which is included in my index.php. the index.php has the doctype as the very first thing.

as for the css id... i'll take a look again... i think i may have multi-used something i didn't originally intend to, thanks.
Aug 15 '07 #20

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Dustin | last post: by
2 posts views Thread by Trent | last post: by
5 posts views Thread by ~~~ .NET Ed ~~~ | last post: by
3 posts views Thread by Roy | last post: by
11 posts views Thread by Ben Holness | last post: by
61 posts views Thread by phil-news-nospam | last post: by
3 posts views Thread by littleark | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.