...

View Full Version : DOM inserted image doesn't inherit text-align



Tails
07-07-2004, 05:35 AM
In a game I made at http://xfox.digibase.ca/games/lights, an image is inserted into the innerHTML of a div when the user wins. All <div> tags use margin:auto as well as text-align:center. Images are inline, so text-align should work (and in every other case in which I tried to reproduce this error, it works fine). This problem happens in Mozilla (works in IE but they treat text-align the same as margin and don't recognize margin). I'm not sure if this is a bug or not (I would have submitted it as a bug if I could figure out exactly what went wrong).

The source of the page is a bit cryptic since I used javascript to write the pattern rather than hard code the entire thing. Mozilla's DOM Inspector can show the DOM structure in real time (the page validates as XHTML 1.1 and is well formed). I guess I'll have to reveal a simple solution to walk you to the win screen. Follow the image index (or see status bar) to click the images in any order prior to scrambling:



1, 2, 13, 14, 0, 4, 8, 15, 7, 11


Is there something that slipped by me? Or is this simply a Mozilla bug?

glenngv
07-07-2004, 11:13 AM
It didn't work because you made img tags as block element.

img{display:block}

Tails
07-07-2004, 05:16 PM
It didn't work because you made img tags as block element.

img{display:block}

I can't believe I forgot that. It's required for tables to fit their content against the borders rather than the baseline. Things like this happen when you haven't touched a project in months. Thanks ;)

Edit: It would be great if the DOM Inspector (or another utility) could display the CSS inheritance of each element in the structure. CSS use is growing more and more.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum