CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 8th, 2008, 04:36 PM
carpeliam carpeliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 carpeliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 58 sec
Reputation Power: 0
Question How can I keep position:fixed elements from falling off the page?

I'm working on a site with a div element with a fixed position, some 800 pixels from the left. The site is optimized for 1024x768. However, if a user with a resolution of 800x600 views the page, this div element will be missing, and the user won't be able to scroll over to see it. Is there some way I can get around this?

One idea would be to align the div on the right instead of the left, but I don't want a lot of whitespace between my content (on the left) and my div (on the right). I was hoping that I could specify a parent element with a relative position, and that position: fixed would reference the position of the parent element, but that only seems to work when the child div element is position:absolute, not position:fixed.

Thanks for any insight.

Reply With Quote
  #2  
Old May 8th, 2008, 05:26 PM
Arem Arem is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 22 Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 15 sec
Reputation Power: 0
I'm new to CSS, but here are some observations, for what they're worth:

800 pixels from let sounds a bit wide to me. I prefer to keep stuff on the screen that everyone will see (horiz scrolling is a pain...)

Anyway, the idea of position: fixed is that the element is fixed in relation to the browser window, not any element on the page. In other words, the fixed element does not move even if the user scrolls down the page.

Quote:
Originally Posted by carpeliam
...I was hoping that I could specify a parent element with a relative position, and that position: fixed would reference the position of the parent element...


No, only position: absolute will reference the parent element. Pos: fixed has a different role.

One thought: You could tell the element to float: right (say within the main div), and then it will always sit on the right-hand side of the page, no matter how wide someone's browser window is. At the moment it doesn't sound like you are using floats, but they are very handy. The rest of your content (perhaps with a fixed width) could float left. To prevent your element floating too far from the left content on wide screens, you could put everything in a main div and apply a max-width: xxxpx; (and maybe a min-width: xxxpx too).

Hope that helps!

Reply With Quote
  #3  
Old May 8th, 2008, 06:20 PM
carpeliam carpeliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 carpeliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 58 sec
Reputation Power: 0
Arem, thanks for your response. I understand my post may be slightly confusing, unfortunately Dev Shed doesn't allow me to create a post containing a URL (I'm still a new user) otherwise I'd send a link.

The element in question is a sidebar, about 200 pixels wide, positioned 800px from the left. The content of the page takes up the first 800px, and the sidebar is on the right. Unless you have a resolution under 1024x768, you won't have any horizontal scrolling.

But seeing as how the sidebar is using fixed positioning, I can't scroll horizontally when it falls off the page, and that's the point. For small resolutions or for people who don't maximize their browser windows, the sidebar becomes invisible.

I'd like to make the sidebar always visible, and always on the right side of the content, without ever falling off the side of the page. I'm beginning to think that I can't do this with CSS alone.


Quote:
Originally Posted by Arem
I'm new to CSS, but here are some observations, for what they're worth:

800 pixels from let sounds a bit wide to me. I prefer to keep stuff on the screen that everyone will see (horiz scrolling is a pain...)

Anyway, the idea of position: fixed is that the element is fixed in relation to the browser window, not any element on the page. In other words, the fixed element does not move even if the user scrolls down the page.



No, only position: absolute will reference the parent element. Pos: fixed has a different role.

One thought: You could tell the element to float: right (say within the main div), and then it will always sit on the right-hand side of the page, no matter how wide someone's browser window is. At the moment it doesn't sound like you are using floats, but they are very handy. The rest of your content (perhaps with a fixed width) could float left. To prevent your element floating too far from the left content on wide screens, you could put everything in a main div and apply a max-width: xxxpx; (and maybe a min-width: xxxpx too).

Hope that helps!

Reply With Quote
  #4  
Old May 8th, 2008, 07:18 PM
Arem Arem is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 22 Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level)Arem User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 15 sec
Reputation Power: 0
OK, I assume that you want the right sidebar to be visible always, even if the user scrolls down.

I'm inexperienced, but I bet you can do what you want with css.

Here's an idea: I would try one big div with position: relative. Inside this put your content and sidebar divs, with absolute positioning. Set a fixed height on the content div (so that it fits on the page) and use {overflow: scroll;}. That way, the sidebar will always be visible on the right and the user will just scroll through the content.

Well, it's a thought, anyway!

BTW, if we can't (as new users) post urls, perhaps we can write them as text, like www dot mysite dot com. Also, when you reply to a post, I would recommend deleting all the quoted material that appears by default.

Reply With Quote
  #5  
Old May 8th, 2008, 07:37 PM
carpeliam carpeliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 carpeliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 58 sec
Reputation Power: 0
Thanks Arem, I understand your idea, unfortunately that's not quite the design we're looking for. I appreciate the suggestions, though.

Reply With Quote
  #6  
Old May 8th, 2008, 09:40 PM
essee essee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 82 essee User rank is Sergeant (500 - 2000 Reputation Level)essee User rank is Sergeant (500 - 2000 Reputation Level)essee User rank is Sergeant (500 - 2000 Reputation Level)essee User rank is Sergeant (500 - 2000 Reputation Level)essee User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 7 h 27 m 10 sec
Reputation Power: 12
Position it from the right, not the left.
ie. instead of

left:800px;

use

right:200px;

That's really about the best way I can think of for this problem.

Another way would be to position you right column absolute based off the screen. Then make your main div 100% width and put the scroll bar on that. Basically the right col floats above the full width main div. Probably end up messy though and possible multiple scroll bars showing up on smaller resolution.

Edit: Just re-read the thread and my second suggestion is basically what Arem said, so scrap that :P.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > How can I keep position:fixed elements from falling off the page?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway