473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to fix a background to a div but not to the browser?

132 100+
Hello everybody,

I'm working on a site which uses divs.
My content in coming into a div with an overflow-y: scroll.

Now I want my background of that div to stay on the same place so I used background-attachement: fixed; which does the trick ofcourse.
However Since my page is quite long, it also automatically has a scrollbar on the side of the browser, when I move that one down, the background of my div doesn't go along, it stays fixed. Anybody any idea how I can solve it so that when the user scrolls inside the Div, the background remains fixed and when a user scrolls the page in total, the background comes along?

Check out http://www.lookandlisten.be/sites/boldgraphics/content/about.htm to see the problem.

Thanks,
Cainnech
Jan 7 '11 #1
4 1585
AutumnsDecay
170 100+
Try:

Expand|Select|Wrap|Line Numbers
  1. background-attachment: fixed;
  2. background-repeat:no-repeat;
  3. background-position: top center;
  4. background:url('images/your_bg.pg');
  5. background-color:#colorcode
  6.  
The background-color you'd use it usually the last colored pixel in your background image.
Jan 7 '11 #2
Cainnech
132 100+
Thanks for the reply AutumnsDecay,

I tried this before and now indeed my background goes along when I use the large scrollbar of the browser but when I use the scrollbar in the div, the background is moving also and I want it to remain fixed in the div.
Jan 7 '11 #3
AutumnsDecay
170 100+
Can you apply the code I gave you and update the site so I can see it for myself? It might give better insight as to what's going on.

Thanks.
Jan 7 '11 #4
Cainnech
132 100+
Oh...
It suddenly hit me. I can solve this by adding another div which just holds the text and not the background and do the overflow-y on that div...

Sorry to bother you guys.
Cainnech
Jan 7 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stephan Koser | last post by:
Hi, I have a problem with the background of a div-layer. A page consists of two div-layers (TOP and MAIN). TOP is a menu-bar and MAIN holds the content. It may be, that MAIN has a width of...
25
by: Neal | last post by:
According to the CSS lint at http://htmlhelp.org/tools/csscheck/, "The shorthand background property is more widely supported than background-color." Can anyone point me to, or provide, information...
33
by: randau | last post by:
Linking to a Targeted Browser Window I'd like to open reference links to other web sites in a separate browser window from the browser window hosting my own web site pages. The Link Target...
9
by: hzgt9b | last post by:
I am using a web browser control to display some PPT slides saved as HTML. My client has recently asked that the background of the browser be changed to sonething other than white so that the...
5
by: Doug Laidlaw | last post by:
HTML validators say that "background" is not a valid attribute for a <td> tag I want to set an image as the background for one cell only, and to have the cell content on top of it. If I can't...
21
by: tradmusic.com | last post by:
Hi, We have the following in our stylesheet, which acts as a page header: #homepageheader { left: 0px; top: 0px; right: 0px; height: 183px; background-image:...
4
by: Philipp Kraus | last post by:
Hi, I have one problem with my position of my background image. I have created one div-tag that has a background image, which should be fixed during scrolling. On the left side of the div is my...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
gauchomatt
by: gauchomatt | last post by:
I have a liquid site which expands perfectly when the browser window is larger than the actual content. However, when I decrease the browser window size to a point that it's smaller horizontally than...
2
by: James Stevenson | last post by:
The website I am working on looks fine so long as the browser window is as wide or wider than the width of the background image. But as soon as I re-size the browser window down to the point where it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.