944,113 Members | Top Members by Rank

Ad:
Nov 6th, 2009
0

can you explain ie7? (fixed position, width 100%)

Expand Post »
I just spent several hours trying to figure out how to fix my websites appearance in ie7. I've found a solution, but I have no clue why it actually worked. I'm looking for an explanation if anyone has one.

My goal was to have a fixed position div across the top of my website. It would have a solid image centered in it that was the width of the content not the screen. When you scroll the page the text should go underneath the bar. I also wanted the bar centered within the width of the screen (since my site is also centered). That way, if the screen was resized the bar would still be centered over the content.

I tried several css methods to achieve this. What I tried worked in EVERY other browser, but not IE7 (don't ask about IE6, I don't develop for it anymore). Here's what I had:
#upperBarWrap {
        position:fixed;	
        text-align:center;
	margin:0;
	width:100%;
}
#upperBar {
	width:1200px;
        height:38px;
	margin:0px auto;
	background-image:url(images/layout/upperBar1.png);
	background-repeat:no-repeat;
	background-position:top left;
	text-align:left;
}

Ie7 didn't know how to handle 100% width. my bar was always ~200 pixels to the right of where it should have been. With everything I tried the bar didn't budge from its off-center position. I finally decided I just needed to effect it somehow. What finally worked was adding a width that only 1e7 could read:

#upperBarWrap {
	text-align:center;
	margin:0;
	position:fixed;
	width:100%;
        *width:1220px;
}
Note that 1220px is the size of the content container div.

This solution really doesn't make any sense to me. Can anyone help me understand why this worked?
Similar Threads
Reputation Points: 10
Solved Threads: 2
Newbie Poster
alipica is offline Offline
13 posts
since Oct 2009
Nov 7th, 2009
0
Re: can you explain ie7? (fixed position, width 100%)
Try this:
HTML and CSS Syntax (Toggle Plain Text)
  1. #upperBarWrap {
  2. margin:0;
  3. position:fixed;
  4. For /* IE */
  5. left: 0;
  6. width:100%;
  7. }
Set 'left=0' property to say IE where the fixed position start.
Reputation Points: 120
Solved Threads: 134
Practically a Master Poster
Zero13 is offline Offline
620 posts
since Jan 2009
Nov 9th, 2009
0
Re: can you explain ie7? (fixed position, width 100%)
Click to Expand / Collapse  Quote originally posted by Zero13 ...
Try this:
HTML and CSS Syntax (Toggle Plain Text)
  1. #upperBarWrap {
  2. margin:0;
  3. position:fixed;
  4. For /* IE */
  5. left: 0;
  6. width:100%;
  7. }
Set 'left=0' property to say IE where the fixed position start.
Even i think this could be a help to you
Or try a support
Reputation Points: 10
Solved Threads: 1
Newbie Poster
rogermatin is offline Offline
14 posts
since Oct 2009
Nov 16th, 2009
0
Re: can you explain ie7? (fixed position, width 100%)
One problem is that you have an invalid style. 0px is invalid. Do not attach a unit of measure to the number 0. Many browsers reject the entire style when this appears.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: a strange problem with ie
Next Thread in HTML and CSS Forum Timeline: <TR> takes viewport size in IE6,7.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC