Forum Moderators: open

Message Too Old, No Replies

Scrollbar moves the frame background along with the content

How can I avoid this?

         

maelstrom

8:11 pm on Feb 11, 2005 (gmt 0)

10+ Year Member



I'm new to the world of website design and I only ended up getting involved to help my aunt out with a website for her small business. I'm trying to teach myself as I go, so I apologize in advance for my ingorance. I'll try to explain the problem I'm having to the best of my ability.

The main page on her site is setup to have 2 frames (header and body I guess) with a background image that carries over from the top frame to the bottom frame. I used photoshop to cut the image into 2 sections and actually managed to get it all to line up real nice. The top frame never changes (it just contains her business logo) and the bottom frame is where all the content shows up. Everything is fine until a page is loaded in the bottom frame that requires a scrollbar. When the scrollbar shows up, it moves the background image on the bottom frame over to the left and out of alignment with the background image on the top frame. Is there anyway to stop this from happening?

tedster

9:14 pm on Feb 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello maelstrom, and welcome to the forums.

I must say, you explained the situation very clearly - well done. There is a "theoretical" fix that keeps the background image from scrolling - but unfortunately Explorer does not support it at this time. The solution is to use CSS and create a background-attachment:fixed; rule for the body element.

However, you may also find that different browsers do not align the two pieces of your background image in the same way - that is a common experience. Different browsers may apply different amounts of "extra" space around each frame by default.

Frames pose many challenges that are not always immediately obvious - such as search engines sending traffic directly to the content page without the complete frameset. That denies your visitors navigation to the rest of the website.

You will probably find better results by eventually redesigning the website so that it doesn't use frames. In my experience, the fact that the navigation scrolls off-screen in a non-framed website does NOT create a problem for many users.

But having visitors from search engines discover a content page that is orphaned from any navigation can be a very frustrating loss of potential business.

There ae still some rare situations where I use a frameset for PART of a website. But I have measured results very closely for nearly ten years over hundreds of different websites and found that using a frameset for the entire website has never been a better design than using "flat" un-framed pages.

maelstrom

10:27 pm on Feb 11, 2005 (gmt 0)

10+ Year Member



I actually did use CSS to place the background images on both the top and bottom frames. The top frame has the background placed bottom center and the bottom frame has the background placed top center. There is no border between the frames. Both backgrounds are fixed and do not scroll up and down along with the text. Here is the CSS I used for the bottom frame:

<style type="text/css">
BODY {
background: white url('graphics/mainimage2.jpg') no-repeat top center;
background-attachment: fixed;
}
</style>

The top frame never has a scroll bar so there is no problem with that frame. The bottom frame lines up perfectly with the top frame as long as the bottom frame doesn't contain text that requires scrolling. If there is an ample amount of text on the bottom frame, the scrollbar appears and the fixed background on the bottom frame gets moved over to the left to make room for the scrollbar I guess. When this happens the backgrounds no longer lineup.

tedster

12:57 am on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see - a horizontal displacement because Explorer calculates a different spot for "center" once the scrollbar appears.

If you can rethink the design so that the background images are postioned in a default manner - begining at (0,0) - I think that would clear up the odd behavior. Of course, I realize that your graphic may not permit this.

It's a tough one. Trying to get ANY image seams to match up over two frames is a major mind melt, and wih background images, you've got quite a challenge. What works in IE on Windows may well break elsewhere.

If the edges of your background are a plain color, maybe you could just use that color for the body background, and then put the content in a div that uses the "real" background image as its background - but experiment with a width of, say, 98%. The body background color could fill in the small gaps at the edges of the content div.

It's going to take experimenting to avoid this IE behavior and find a part of their rendering engine that behaves as you hope.

What DTD are you using? You may get better results if you make sure the browser is in standards mode instead of quirks mode.

kaled

10:33 am on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bear in mind that, when using fixed background images, scrolling will be slower since the whole viewport image has to be redrawn. Otherwise, scrolling involves moving part of the screen image and redrawing only the newly visible part.

With simple images/pages and modern hardware, there is not usually much of a problem but complex pages on old hardware - that is a different story.

Kaled.