Reply
problem using position in divs
Old 05-21-2006, 09:54 AM problem using position in divs
Average Talker

Posts: 20
I am having problems with these relative positions - i thought they are relative to the containing div - but i must be doing something wrong.


But - i can not get the 2nd and 4th divs to position opposite the headings.
eg alongside the Agency name: i want to position the input box which has the initial value of Private.

and alongside Your refference i want the other input box (div4)

I have set them both at top:0 and stii they are about 40px lower than where i want. I thought that top:0 would be relative to the containing div (layer3)
but it doesn't seem so ??

here is the code:
thanks again if you can put me straight
HTML Code:

<!-- START OF LAYER 3 -->
<div id= 'layer3' style='width:260px; height:250px; background-color: #ffff00;width:260px;position:absolute;left:10px; top:300px;' >
<center><b>For Agents Use.</b></center>
<div style='width:240px;position:relative;left:10px; top:20px;' >
Agency name:<br>
<span class="det1">If you are acting as an agent for the company -
please put your agency name. If not, leave as 'Private'.</span>
</div>


<div style='width:200px;position:relative;left:120px; top:0px;' >
<input type="TEXT" name="x_agent" value = "<?php echo $N_agent ?>"
size = '15' maxlength='40'/>
</div>

<div style='width:240px;position:relative;left:10px; top:20px;' >
Your reference:<br>
<span class="det1">If you have several adverts running
you may want to use reference numbers. You can use numbers or letters. (optional)</span>
</div>

<div style='width:200px;position:relative;left:120px; top:0px;' >
<input type="TEXT" name="x_opt_yr_ref" value = "<?php echo $N_opt_yr_ref ?>"
size = '15' maxlength='20'/>
</div>

</div> <!-- END OF LAYER 3 -->
Jetti is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-21-2006, 11:45 AM Re: problem using position in divs
chrishirst's Avatar
Super Moderator

Posts: 13,609
Location: Blackpool. UK
<div>s are a block element so have an implied line feed before and after them.
to align them side by side you either need to float them ( float:left | right | none) or use display:inline depending on what will work best for your design.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2006, 02:30 PM Re: problem using position in divs
Average Talker

Posts: 20
so - none of you guys know how this works ????
Jetti is offline
Reply With Quote
View Public Profile
 
Old 05-22-2006, 03:20 PM Re: problem using position in divs
chrishirst's Avatar
Super Moderator

Posts: 13,609
Location: Blackpool. UK
well maybe we thought you could see for yourself

you have a container 260px wide then in it there is a block element 240px wide and one 200px wide. So your maths are a bit off there.

<div>s will not sit adjacent each other unless you follow the steps outlined in my first post.

So what have you tried up to now ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2006, 05:52 PM Re: problem using position in divs
LadynRed's Avatar
Super Moderator

Posts: 6,555
Location: Tennessee
Quote:
i thought they are relative to the containing div
They are, but there are other things that will affect positioning too.

It's also not generally necessary to position EVERY single div on a page. Position what you must and use source order to let the content in the page flow.

Put in a wrapper with a defined width that will enclose all your other elements. Make it position: relative. Then see where the rest falls without positioning inside it. Absolute positioning takes that div OUT of the document flow. Why are you absolutely positioning Layer3 ??
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-24-2006, 09:35 AM Re: problem using position in divs
Average Talker

Posts: 20
Thanks for your help.

I didn't realise hat I could 'overlay' a div ontop of another one.

any way ı got rid of two of the dives and ended up with a nice layout.

thanks again.
Jetti is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to problem using position in divs
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.35950 seconds with 12 queries