div tag

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

div tag

Post by ekosoftco »

im trying to get a div to absolute position, so when the user makes the window size change, things are in the right spot still. im using this code

Code: Select all

<div style="position:absolute; left: 311px; top: 257px; width:200px; height:26px; z-index:1;">
___ Accounts Active!
</div>
but it still doesnt work. ive also tried it in css script in the head of my page, does the same thing.
anyone have any ideas?
my example is here
http://cyril.ulmb.com/game/gamestory.php
the thing that says accounts active needs to stay on the black,
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Post by kaszu »

If you use position absolute, left and top, then div will be positioned relatively to the window.
If you want it to be relative to the parents position use margin-left and margin-top instead of left and top.

Could you explain a little more specific, what exactly are you trying to achieve?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Absolute positioning on it's own should be avoided. However, mixing absolute positioning with relative positioning can work well.

Code: Select all

<style type="text/css">
.outer {
    position: relative;
}

.inner  {
    position: absolute;
    top: 0px;
    left 0px;
}
</style>
<div class="outer">
    Outer
    <div class="inner">
        Inner
    </div>
</div>
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

Post by ekosoftco »

if you go to the link for my example youll see more of what i mean. the part that says _ Accounts Acitve is in a div, i need that div to stay in the black square whether the window is max, or any other size.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Did you even try using relative and absolute positioning together?
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

Post by ekosoftco »

yeah, it does the same thing, its on that page i put in the first message now.
anyone know? or mind taking a look to see what i mean?
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

Post by RobertPaul »

Why are you trying to position div1 and div2 over the table instead of putting them inside of it?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

ekosoftco wrote:yeah, it does the same thing, its on that page i put in the first message now.
Because you just randomly added another div around it. You need to make the objects a part of the layout if you want it to flow with the layout, not just some randomly placed element outside of the layout.
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

Post by ekosoftco »

Why are you trying to position div1 and div2 over the table instead of putting them inside of it?
when i put php inside a row in the table, it makes the table size larger than i want it to be. i wanted to table as tall as the text, but even if i set it to that, it automatically becomes larger.
i really didnt feel like doing the entire site in div, it works just fine with tables besides that one part.
:/
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

Post by ekosoftco »

im retarded. i had 2 breaks in echo in my php. oooppss my bad. xD
let this be a lesson, look at your script better, or youll post and get headaches like me.
Post Reply