Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-20-2005, 06:44 AM
MrLeN's Avatar
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 541
MrLeN RepRank 0
Default Absolute Positioning CSS

I have a problem that I've been trying to sort out for 2 days, but it doesn't matter what I do, each thing I try almost works, but presents a new problem in at least one browser.

Ok, first, the scenario.

I have a website which is set at 770px wide. So of course in resolutions like 1024, there will be some white area on each side of the template, because the template is "centered"

Now, that's all baby coding. But here's my problem. I want to absolutely position some text into the template. The problem is, I have nowhere to justify the positioning from.

I thought I'd be tricky and make a div and absolutely position that div 50% from the left (that gives me a center), and then put another div inside that div and give in a minus left margin, which pulls the text over to the position I want.

The problem is that the first div causes the bottom scrollbar to show, because it's hanging off the page 50%. I made that div 1% wide, but then it either cuts the text of the div inside it, or just gets displayed as 100% anyway, depending on which browser.

Now I am sure that someone has a way to absolutely position a div on a centered template, but I certainly haven't been able to figure it out. Anyone?

MrLeN
Reply With Quote
  #2 (permalink)  
Old 10-20-2005, 07:03 AM
MrLeN's Avatar
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 541
MrLeN RepRank 0
Default

Here's the best I have come up with so far.



It works in Firefox and Opera but not in IE:



CSS

Code:
.description1 {
position: absolute;
top: 190px;
left: 50%;
width: 1px;
}
.description2 {
margin-left: -190px;
width: 590px;
font-family: verdana;
font-size: 11px;
}


HTML

Code:
<DIV class="description2">
<SPAN class="description1">Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text</SPAN>
</DIV>
MrLeN
Reply With Quote
  #3 (permalink)  
Old 10-20-2005, 07:08 AM
MrLeN's Avatar
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 541
MrLeN RepRank 0
Default

I can't believe the answer was so simple. Why on earh was I tying to use 2 layers? I don't know. Here's the answer:

CSS
Code:
.description {
	position: absolute;
	top: 200px;
	left: 50%;
	margin-left: -190px;
	width: 590px;
	font-family: verdana;
	font-size: 11px;
}
HTML
Code:
<div class="description">Text Here</div>
Thnaks for all your help. I donno what I would do without this place!

MrLeN
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0