473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

background-color on HTML or BODY?

HaLo2FrEeEk
404 Contributor
I'm working on a project that has a background image which needs to be repeated on the x-axis. There will be elements which have transparency overlaying the background image as well. Logically, I set the background attribute of the BODY element in my CSS:

Expand|Select|Wrap|Line Numbers
  1. body {
  2.   background: #494949 url(http://example.com/myimge.png) repeat-x;
  3.   }
To my surprise, this worked in IE9, Firefox, Opera, and Safari, but not Chrome. Every other browser performed as expected, but Chrome wouldn't show the background image. So I tried changing the rule to html, body{}, now what was happening was, in Chrome, the background image showed up on the background of the page, but the body element wasn't getting the background image. Every other browser showed an instance of the background image on the HTML element, then another, slightly offset, on the BODY element. In addition, the transparent element wasn't showing through to the backgound image, since the body background had a color of #494949.

Finally, I tried separating the HTML and BODY rules:

Expand|Select|Wrap|Line Numbers
  1. html {
  2.   background: #494949 url(http://example.com/myimage.png) repeat-x;
  3.   }
  4.  
  5. body {
  6.   background-color: transparent;
  7.   }
And that worked in all browsers.

My qustion is, is this normal behavior? I've always applied background images to the BODY element, have I been doing it wrong? Is this a good wa to accomplish what I'm going for? I don't want to hack together my CSS, I want to get this right.
Mar 21 '11 #1
3 2225
drhowarddrfine
7,435 Recognized Expert Expert
Your first example worked the same for me in Chrome as it did in FF and IE9.
Mar 21 '11 #2
JKing
1,206 Recognized Expert Top Contributor
It should be set on the body. I tried to replicate this issue but to no avail.

Are you still experiencing this?
Mar 22 '11 #3
HaLo2FrEeEk
404 Contributor
Nah, I got it fixed by setting the image and page background color in the HTML ruleset, and setting the body background color to transparent with a BODY ruleset. I works in all browsers I've tested it in.
Mar 24 '11 #4

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

Similar topics

4
2489
by: Dj Frenzy | last post by:
Hi, I know how to use javascript to change a background image to another background image, and how to change a background colour to another background colour. Is there a way to change an image to a backgound colour? I have a table with a background that has a picture. When the user hovers over the picture I want the background to change to the background colour of the rest of the page, as if to make the picture disappear.
7
5805
by: ryan.fairchild | last post by:
Ok I basically am creating a container for a bunch of other <div> tags. But I want to make four jpegs/gif/whatever that goes in each corner so they look rounded. I thought this is how I would do it but I could be wrong. body { background:#999 url("http://") no-repeat top left; background/* */:/**/url("http://") no-repeat top right; background: /**/url("http://") no-repeat top right;
2
42496
by: day | last post by:
I'm trying to use a non-scrolling background image within a div (the non-scrolling part is a "nice-to-have" vs a "have to have"). The style for that is: <div style="height=400px; background-image:url(bgrd-foo.jpg); background-position: center top; background-repeat:no-repeat; background-attachment: fixed;">
1
3307
by: RJ | last post by:
Hello! I am trying to lay out a left navigation column with a background image, where the left nav column runs the entire scrolled height/length of the page. The float:left column layout works fine, but the background image doesn't continue downward in this column below the links. I tried this in FireFox 1.0.7 and IE6, but this image stops where the last link stops. I want the background all the way to the bottom. How can I force...
0
4435
by: naamad | last post by:
Hi, My problem seems to be simple but after reading and investigating a little I realize it is quite complex: I have a treeview derived control, and I want this tree view to be shown with a background image. I tried 2 options: 1. Put the tree on a panel, set it to transparent (using the appropriate ControlStyle - ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint) and put a background image on the panel. The background...
3
3243
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in question: www.sayatnova.com (I'm sure many of you have seen this before as I've often asked for help). I've come a long way since I first created the site many moons ago and I'm trying to convert it to a (1) Table-less, (2) Frame-less and (3) Validated...
6
9678
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want the posting confirmation page to end displaying quickly, without waiting for those notifications or other tasks to complete. So basically what I want is to launch 'background.php' from 'main.php', with the user seeing only the output of - and...
8
5370
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In this code there is a panel panel1, that I populate with a lable in the foreground. Then when I click on "button1" a backgroundworker thread in async mode is started. When the backgoundworker thread completes the thread returns a panel to populate...
18
2612
by: LayneMitch | last post by:
Hello. After getting great advice on positioning, I've edited my code and it's looking more stable. Now I need a little assistance with background image placement. Please click on this link: www.ibtestsite.info I've colored the background black and added a background image which is the
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.