1
tsnto
Background image
  • 2004/2/14 10:38

  • tsnto

  • Just popping in

  • Posts: 2

  • Since: 2004/2/14


Hi!I've a little problem.I want to insert the same image on the background of all site pages.
I know that I must modify the file style.css but I'm not a wizard in html programming so,
is there someone can help me?Thanks

2
TooBaked
Re: Background image
  • 2004/2/14 10:54

  • TooBaked

  • Just popping in

  • Posts: 37

  • Since: 2003/2/9 5


use this in top of CSS file of your theme

background-image: url(images/pc_bg.gif);

Edit In: /path_to_xoops/themes/your_theme/style.css

Place image in /your_theme/images/

Example:
body { color: #000000; background: transparent; background-image: url(images/pc_bg.gif); margin: 0; padding: 0; font-size: 9px;}
hr {color:#9FBCE3; height:1px;

3
philou
Re: Background image
  • 2004/2/14 13:25

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


you had an other solution....
a little bit complex...

To display different background images to fit visitor's resolution screen
It is simply solved with a javascript resolution test to build the BODY tag on demand
The var use limit this script to be used with internet explorer only
It needs to adapt theme.html in its BODY part :
<SCRIPT LANGUAGE=javascript>
if (
screen.height<=600
 {
  
document.write('< BODY background="imgages/fdacc800.jpg" leftmargin=0topmargin=0bgproperties=fixed>');
 };
if ((
screen.height>600)&&(screen.height<=768))
 {
  
document.write('< BODY background="imgages/fdacc1024.jpg" leftmargin=0topmargin=0bgproperties=fixed>');
 };
if (
screen.height>768
 {
  
document.write('< BODY background="images/fdacc1280.jpg" leftmargin=0topmargin=0bgproperties=fixed>');
 };
</
SCRIPT>
Note : delete space before BODY

4
Kent
Re: Background image
  • 2004/2/14 15:01

  • Kent

  • Just popping in

  • Posts: 15

  • Since: 2002/4/19


Instead of using the document.write() you should just change the element you want to work with. Here's how you can change it without breaking an html page for someone who's Javascript is turned off:

<script language="javascript1.2" type="text/javascript">
function 
setBackgroundImage() {
  if (
screen.height <= 600) {
    
document.body.style.background="images/background600.jpg";
  } else if (
screen.height 600 && screen.height 768) {
    
document.body.style.background="images/background768.jpg";
  } else {
    
document.body.style.background="images/background1024.jpg";
  }
}
</
script>


Note the compression in the JavaScript. Now you can use onLoad="setBackgroundImage()" in the body tag to call it. Doing this won't remove the body tag from the html. The only problem using this method is the image won't load with until the entire page has been loaded already; however, there is a workaround by using this method:

image600 = new Image();
image600.src "images/background600.jpg";


However, this also has a problem. Using the preloading of images will load other useless images wasting download time. A way around that would be to only use the onLoad functionality.

Now then...
- DO NOT USE the screen height.
- DO NOT MAXIMIZE the window for the screen.
- DO NOT USE popups unless it's from a link the user clicks on.
- DO NOT MOVE the window.

Taking control away from a user only pushes people away from your web site. I don't know how may sites try to do this to make their web site look "cool". Instead set the initial table width to 784 (default width of 800x600 display size with a maximized browser window with margin set at 5). Then, gather the current width of the window using window.innerWidth (or document.body.offsetWdith if you are using IE). Using the current width of the screen you can then safely set the table or div size. I would recommend using table over div as there are still some browsers out there which do not support span or div properly. I've been a web developer since before html became a standard.


5
Kent
Re: Background image
  • 2004/2/14 15:23

  • Kent

  • Just popping in

  • Posts: 15

  • Since: 2002/4/19


Okay, going to write this real quick to show how to set the width and height for loading a specific graphic.

<script language="javascript1.2" type="text/javascript">
  <!--
    function 
getWindowSize() {
      var 
winW 784;
      var 
winH 632;

      if (
parseInt(navigator.appVersion) > 3) {
        if (
navigator.appName == "Netscape" || navigator.appName == "Opera") {
          
winW window.innerWidth;
          
winH window.innerHeight;
        }
        if (
navigator.appName.indexOf("Microsoft") != -1) {
          
winW document.body.offsetWidth;
          
winH document.body.offsetHeight;
        }
        
// Additional browser check here.
      
}
      return 
winW;
    }
    
// A change to the original setBackgrondImage()
    
function setBackgroundImage() {
      if (
getWindowSize() <= 600) {
        
document.body.style.background "images/background600.jpg";
      } 
// ... insert the rest here accordingly
    
}
  
//-->
</script>
< /
head>
body>
  <!-- 
your html page here //-->


Browsers not supporting CSS will still display the pages just fine without the background image. The only concern you should think about is finding the average color of the background image and use that as the background color (< body bgcolor="#xxxxxx"). That way you don't end up with white text on a white background for people who surf without loading images.

When it comes down to JavaScript, I like taking a much more object driven approach rather than putting the script into the html pages. Use the attribute "src=" to set where the external ".js" file is located. If you go about using the preload method than just change the lines to something similar to this:

document.body.style.background image600.src;


I haven't tested this script... but it should work without any problems.


6
Mithrandir
Re: Background image

I have a related problem here.

I have a rather large background image (1280x1024) which I would like to put in the background of a site.
It works fine with 800x600, but as soon as I change the image size to a bigger one, it won't load.

It could be a problem with my locally hosted server - I must admit, I haven't tried it with a better host - but I just wanted to know if there were other things, I could blame before going overboard with uploading things to external hosts etc.

Thanks in advance

7
Mithrandir
Re: Background image

Nevermind - it seems to be a problem with my local apache + WinXP webserver.
I suffer from breakups in code in PHPMyAdmin and other deficiencies on that webserver anyway, so I know I cannot trust it too much.

8
phatty
Re: Background image
  • 2004/4/1 6:57

  • phatty

  • Just popping in

  • Posts: 70

  • Since: 2004/3/9 2


Hi, I have the same problem. Can't get my image to show up in the background. Here's what i've added to my .css file but my background just comes out white.

body {color: #000000; background: transparent; padding: 0; margin: 20px; background-image: url(images/lzmsg.jpg); }
body, td, th, p, div {font-family: Verdana, Arial, Helvetica; font-size: 11px;}


Can someone please assist. I've read every post here and tried everything. I don't understand .css very well.

Jeff

9
HughG
Re: Background image
  • 2004/4/1 7:04

  • HughG

  • Not too shy to talk

  • Posts: 124

  • Since: 2003/2/21


Quote:

background-image: url(images/lzmsg.jpg); }


thats assumes your bg image is sitting the the "images" folder. if it's sitting in the themes folder remove the images/
example:

background-image: url(lzmsg.jpg); }

10
phatty
Re: Background image
  • 2004/4/1 7:19

  • phatty

  • Just popping in

  • Posts: 70

  • Since: 2004/3/9 2


I've got the image in both places and still no go...

Any other ideas??

Jeff

Login

Who's Online

187 user(s) are online (103 user(s) are browsing Support Forums)


Members: 0


Guests: 187


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits