| Web Design Lobby Forum for general web design issues not specific to scripting or graphics. |
02-16-2004, 04:27 PM
|
#1 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
IE Dynamic CSS position:fixed; cross-browser solution by LJ
It's the best fix for IE not supporing the CSS property "position:fixed;"...
I done an alternative CSS+Dynamic Properties (IE only) solution to make IE do position fixed, and no extra code needed on the element itself!
it's all in the CSS, but scripts probably still have to be enabled in the browser.
IE5+ I think.
check it out the IE version of position:fixed; here!
http://dev.jdenny.co.uk/css/ie_fixed.html
*edit* updated to include a fix for background-position: fixed;
|
|
|
02-16-2004, 05:59 PM
|
#2 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 275
Latest Blog: None
|
That's cool.  Nice find. 
|
|
|
02-16-2004, 06:04 PM
|
#3 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
Find?
what u mean find?
I never seen this anywhere else I had to make it!!!
|
|
|
02-16-2004, 07:39 PM
|
#4 (permalink)
|
|
Inactive
Join Date: 01-28-04
Posts: 84
Latest Blog: None
|
Can i use for a bg image?
|
|
|
02-17-2004, 03:46 AM
|
#5 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
I don't know, try it 
|
|
|
02-17-2004, 07:23 AM
|
#6 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
It sort of works I think, not finished testing.
I trying to add a patch to the background effect: http://www.meyerweb.com/eric/css/edg...iral/demo.html
But the major problem comes from style rules cascading and so measurements are applied to the parent elements depending on how the CSS selector is written.
|
|
|
02-17-2004, 08:58 AM
|
#7 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
OK well it would be nice to do it all in CSS (+MSIE expression()s ) but it would be easier in JavaScript...
Does anyone know any mroe about expression() for setting CSS property values?
Specifically I want to know how to reference the current element being worked on by the browser...
for example:
If I hade this HTML
[code:1:d48ef44df6]
<ul id="nav">
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
</ul>[/code:1:d48ef44df6]
then in my css I wanted to give each <li> a background image with a position that is 0-h where h is the <li>'s distance from the top of the page (for sake of argument I have a javascript funciton to work out h called getH(oElement) and it takes the element as a parameter)
[code:1:d48ef44df6]
#nav li {
background-image: url('my_bg.gif');
background-position: expression("0 "+getH({reference to current element}) );
}
[/code:1:d48ef44df6]
{reference to current element} is the thing I need, it is a reference to the <li> element that the CSS is currently working on.
having access to {reference to current element} would save me having to do this:
[code:1:d48ef44df6]<ul id="nav">
<li id="nav_item_1">list item 1</li>
<li id="nav_item_2">list item 2</li>
<li id="nav_item_3">list item 3</li>
<li id="nav_item_4">list item 4</li>
</ul>
<style>
#nav li {
background-image: url('my_bg.gif');
}
#nav_item_1 {
background-position: expression("0 "+getH(document.getElementById('nav_item_1')) );
}
#nav_item_2 {
background-position: expression("0 "+getH(document.getElementById('nav_item_2')) );
}
#nav_item_3 {
background-position: expression("0 "+getH(document.getElementById('nav_item_3')) );
}
#nav_item_4 {
background-position: expression("0 "+getH(document.getElementById('nav_item_4')) );
}
</style>[/code:1:d48ef44df6] which is obviously too much code and too much maintenance.
|
|
|
02-17-2004, 09:03 AM
|
#8 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 275
Latest Blog: None
|
By nice find, I mean that you had to find the super uber cool inspiration to think of it. 
|
|
|
02-17-2004, 09:20 AM
|
#9 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
my apolodies, it appears to be the first thing I tried: you can use the "this" special word used in JavaScript - for some reason the first time I tried it, it didn't seem to work!
So anyway {reference to current element} = this
|
|
|
02-17-2004, 09:22 AM
|
#10 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
Quote:
|
Originally Posted by Distorted
By nice find, I mean that you had to find the super uber cool inspiration to think of it. 
|
oooh right! hehehe i'll belive ya! 
|
|
|
02-17-2004, 11:30 PM
|
#12 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 275
Latest Blog: None
|
Wow, it's really improved. Now it doesn't skip like it used to.
This reminds me, I need to learn javascript. 
|
|
|
05-01-2004, 10:30 AM
|
#13 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
I found out how I stopped it skipping and wobbling!
put this CSS in your page for any CSS IE fixed poistion fix you want to use:
[code:1:ddc912613d]body {
background-image: url(false_url);
background-attachment: fixed;
}[/code:1:ddc912613d]
|
|
|
05-03-2004, 01:16 PM
|
#14 (permalink)
|
|
Inactive
Join Date: 12-27-03
Location: Russia, Nizhny Novgorod
Posts: 116
Latest Blog: None
|
LazyJim, in this situation it's possible to use position: absolute i think. 
|
|
|
05-03-2004, 05:23 PM
|
#15 (permalink)
|
|
Inactive
Join Date: 10-13-03
Posts: 275
Latest Blog: None
|
No, position absolute and fixed are two totally different things.
Absolute just makes something a certain number of pixels from the edges when the page loads, but fixed makes that same thing stay, even if the page is scrolled.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:25 AM.
© Copyright 2008 V7 Inc
|