Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-02-2006, 10:36 AM   PM User | #1
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
absolute positioning

how do I set absolute positioning for a span but only within the div I am in?
without it looking to where it is the actual whole page
esthera is offline   Reply With Quote
Old 11-02-2006, 10:57 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,696
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
I hope I understand this right: You want to position a span absolutely but it must stay within the borders of the containing div?

In that case you need to set position: relative for the div and then the span will be positioned according to the div's position.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-02-2006, 11:00 AM   PM User | #3
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
i want to position multiple span in 1 div all absolutely -- but in the next div again do the same thing but to that div and not to the whole page.

so i do position:relative for the div - but what about the span? (of do I just set the pixel amount in the span?) Is there anyway to easiily measure where something would go if I have a backround image and want to fill in set places?
esthera is offline   Reply With Quote
Old 11-02-2006, 11:22 AM   PM User | #4
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
I tried but it didn't work - I set the div to be relative and then the span to be

.x{

left:50px;
top:100px;
}

but it just stayed in teh top corner and ignored teh postiining of the span. why?
esthera is offline   Reply With Quote
Old 11-02-2006, 02:36 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,696
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Yeah of course it stayed there because that only works in conjunction with positon: absolute/relative;. You almost got ist. Just apply position: absolute; to your spans and it should work.

In a nutshell:
  • div needs position: relative;
  • span needs position: absolute; and a specific position (top, left, right, bottom)
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-02-2006, 05:57 PM   PM User | #6
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
thanks for your help -- this is what i needed to know.

one more thing --

if i have

<span class=three>
date is here<br>
This is site info<br>
and more

</span>

and the class is
.three{
position: relative;
left:360px;
top:148px

}

for some reason the first line of the thml is indented more then the rest.
why?
esthera is offline   Reply With Quote
Old 11-02-2006, 06:56 PM   PM User | #7
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,696
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
You should learn about positioning, I guess, because there are some traps that especially inexperienced people always fall for.

Haven't read all through these sources but I think they will give you an idea:

http://www.webreference.com/html/tutorial18/
http://www.brainjar.com/css/positioning/default2.asp

You probably don't need any positioning at all and should rather work with floats and margins to position your elements.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-06-2006, 11:13 AM   PM User | #8
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
I have my div with postion:relative;

then i have a span with the css of

.three{
position: relative;
left:360px;
top:148px

}

but when i add text or another span to the same div. the span moves over a bit - I want it to be always positioned in the same place in the div - no matter if things are added or not? how do i do this?
esthera is offline   Reply With Quote
Old 11-07-2006, 12:55 PM   PM User | #9
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,696
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Make the span position: absolute;?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 AM.


Advertisement
Log in to turn off these ads.