Log in

View Full Version : <div> fixed bgimage



chechu
12-26-2006, 11:21 AM
<div style="width:521px;height:252px;overflow:auto;">

I use the above code to avoid using <iframes>. But how can I make the background-img fixed, instead of scrolling with the content ?

djr33
12-26-2006, 11:23 AM
K. Well... you already asked this, but, yeah, this is a better place for it.
Just search this forum... there have been a lot of threads about it. (maybe css or graphics, too, perhaps)

Twey
12-26-2006, 08:09 PM
background-attachment: fixed;

chechu
12-27-2006, 09:27 AM
So I placed this, but it won't stay fixed:

<div style="width:521px;height:252px;overflow:auto;background-attachment: fixed;">

<table width="100%" height="100%" background="bgpalet.gif" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle">
...(content)

Twey
12-27-2006, 11:32 PM
Why are you using CSS in one element, and obsolete presentational HTML in another?
<div style="width:521px;height:252px;overflow:auto;">

<table style="width: 100%; height: 100%; background: silver url(bgpalet.gif) fixed; border: 0 none;" cellpadding="0" cellspacing="0">
<tr><td style="text-align: center; vertical-align: middle;">

chechu
12-28-2006, 09:56 AM
Twey, the problem has not been fixed with the code you proposed.

jscheuer1
12-28-2006, 04:01 PM
The fixed value for the background attachment often works counter-intuitively and the way it is supported varies among browsers but, those that do support it (all modern browsers) do so in a similar, if not identical fashion. The most reliable element to use it with is the body. In your case it should be applied to the element that scrolls:


<div style="width:521px;height:252px;overflow:auto;background: silver url(bgpalet.gif) fixed;">

<table style="width: 100%; height: 100%; border: 0 none;" cellpadding="0" cellspacing="0">
<tr><td style="text-align: center; vertical-align: middle;">

Make sure that no other css rules in a stylesheet or elsewhere give any background to the table, its body, rows, cells and any of its cells' contained elements. If they do, those backgrounds will obscure the division's (or any underlying element's) background.

chechu
12-28-2006, 04:43 PM
Works perfectly.
Thank you so much !