![]() |
CSS Div Question
Alright, this is a really important question, and I really need help, Ive been stumped for awhile.
What I need is to have the "map" div somewhere, and in it have several other divs, but each of the divs within needs to have a relative position starting at 0; thats the only real way my MMORPG can be browser compadible, because otherwise I will have to caculate exact measurements of where the map displays (for position absolute), and that wont be constant. I have the image of the map floated, because anytime I tried to add a div everythings relative position matched it, so I had to just float the image, adding the image as a background-image attribute to map was a failure because the image file is updated constantly (via php and gd) and the background would be cached. Anyways heres what I have: :
<style type="text/css">dispobj did display perfectly fine until I added in the div containing the image, then that div and dispobj div's relative position moved to below the map. What can I do? Absolute positioning is what I REALLY want to stay away from. |
I cannot comprehend exactly what your problem is. Posting a before and after image of what you are trying to accomplish would definitely help.
From what I understand, it sounds like you are trying to align objects in a certain way, perhaps in a grid. If this is a case, you should use an HTML <table>. |
It may be that he wants to display certain images on top of other images, and relative positioning doesn't inherently allow overlaps. I wonder; what happens if you float your #dispobj?
|
Sorry, I know my explanation was really confusing. What im trying to accomplish is have the map image layered [at the bottom layer] at relative position 0, 0 within the map div. Then each div layer ontop of the map, I want to be able to position with the top and left values from the top and left within the map div, not from the page, and not relative to the object before it. A table would be too much loading, too much for the browser to download [and actually wouldnt even work, as some tiles are bigger than others].
Absolute positioning is sort of what I want, except I want the absoluteness to start at the top left corner of the map div, not of the page. :
<div class="map">Something of that effect, where each of those divs would position absolute, within the div "map", not of the page (since the div will display at diffrent places)... javascript calculation is something I dont want, position absolute and manually adding in a number to compensate for the maps offset on the page is also something I dont want. |
Absolute positioning is not always relative to the page. If the enclosing container is positioned relative, the enclosed container, if positioned absolute, will be absolute with respect to the enclosing container. Sounds sort of confusing, I know.
Here is some sample code. The page div has relative positioning so that absolute positioning will be relative to it. The menuContainer div is positioned relative for the same reason. The menu, a contained list, is positioned only with padding. The menu shadow, a div, is positioned absolute. The positioning is relative to the enclosing menu container (which is positioned inside the page div only by margin). The shadow is z-indexed below the page so that text is above it. The menu is z-indexed above the page. Text wraps around the menu container because the container is floated left. Its width is fixed, so that the shadow, though contained, can extend beyond it, to the right, into the text. I don't know if this will be of any help, I just thought I'd toss it out here. Bear in mind that IE has box dimensioning problems in that margin/padding numbers don't accumulate properly. It also has problems with determining the correct enclosing container. I didn't have to hack that in this particular instance, but sometimes it's necessary. It did give me problems with the shadow matching the menu when an item in the menu expands. Forgive the large tabs. I just copied and pasted portions of this into Wordpad; should have used another editor. You can see this at either of the Contributor's Corner links in my signature. :
<body> |
Thank you! Problem solved!
|
Quote:
|
It is entirely possible to make a table with tiny cell sizes and adjust it accordingly by combining certain numbers of columns and rows. There was a time when it was the only reasonable solution. Those days are gone. Tables are not evil, but they should be use to present tabular material. Don't tune your carburetor by enlarging the jet with chewing gum. It may work, but it's schlocky , unprofessional, and subject to unanticipated failures.
|
Yeah, but what im saying is my map is 32 x 24, so multiply that, and thats the amount of TD's generated minimaly. Now each TD call will include a class name too, so thats about 15 bytes each sent to the browser, now multiply 15 bytes x 24 x 32... way more than some simple divs. Plus if any tile were to be bigger than 16 x 16 [which currently half the tiles are], tables would completely not work.
|
| All times are GMT -5. The time now is 12:52 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC