Hintergrundbild skalieren...

Status
Nicht offen für weitere Antworten.

MsvP

Gesperrt
Ich hab da mal ne Frage! *fg

Und zwar mache ich gerade ne cs seite für nen freund! auf der site habe ich den Banner als Hintergrund gemacht! Jetzt ist das prob, dass ich möchte das sich der Banner der Auflösung anpasst! Da momentan noch bei ner anderen auflösung als 1024x768 der banner sich entweder wiederholt oder zu klein wird!

Womit mache ichd as am besten?! CSS?! Oder gibts ne html möglichkeit?

Danke für eure hilfe gre@tz Msv P!!!
das is die seite übrigens:
http://geocities.com/cksmoden/fischer.htm
 
Hallo,

mit CSS oder HTML kommst da nicht weit, aber du kannst mit JavaScript die Auflösung abfragen und dazu dynamisch das Passende Stylesheet nachladen. In den Stylesheets kanns du ja verschiedene Hintergrundbilder einbinden...

PHP:
function SetCSS() {
  css="basic_1024.css";  
  if (screen.width==800)  css = css.replace "1024.css","800.css");      
  if (screen.width >1024)  css = css.replace    "1024.css","1280.css"); 
  }
  document.write ('<link rel=stylesheet type="text/css" href="../style/' + css+'">');  
}

Der Code ist von SelfHTML Ich würde das Script zwar etwas anders aufbauen, hab aber grad keine Zeit dafür ;)




CU Andreas
-------------------------------------------------------------
"There are only 10 types of people in the world, those that understand binary, and those that don't."
 
PHP:
function SetCSS() {
    css = "basic_1024.css";  
    if (screen.width==800) {
        css = css.replace("1024.css","800.css");
    }
    if (screen.width >1024) {
        css = css.replace("1024.css","1280.css");
    }
    document.write ('<link rel="stylesheet" type="text/css" href="../style/' + css+'">');  
}
bzw.
PHP:
function SetCSS() {
    css = "basic_1024.css";  
    if (screen.width==800) {
        css = css.replace(/1024.css/,"800.css");
    }
    if (screen.width >1024) {
        css = css.replace(/1024.css/,"1280.css");
    }
    document.write ('<link rel="stylesheet" type="text/css" href="../style/' + css+'">');  
}
wäre die funktionierende Syntax mit der replace()-Methode.
*cronos zeitproblematisches Script mal ergänz*

;)

Aber warum replace(), wenn du einfach auch die Variable neu setzen kannst...
PHP:
function SetCSS() {
    css = "basic_1024.css";  
    if (screen.width==800) {
        css = "800.css";
    }
    if (screen.width >1024) {
        css = "1280.css";
    }
    document.write ('<link rel="stylesheet" type="text/css" href="../style/' + css+'">');  
}
Geist
 
Danke für die Ergänzung :) Das Script war nicht von mir - habs auch nicht getested. Ich für meinen Fall hätte eher mit irgendwas in Richtung
PHP:
if(screen.availHeight < xxx)
document.getElementsByTagName("body").style.backgroundImage = "x.jpg";
gearbeitet (wenn ich die Zeit hätte das richtig zu testen :rolleyes: )




CU Andreas
-------------------------------------------------------------
"There are only 10 types of people in the world, those that understand binary, and those that don't."
 
Schon klar, hab' das auch so rausgelesen gehabt, dass du per c&p das Script reingeholt hast. :)

Sollte ja in dem Zusammenhang auch kein Vorwurf sein...

Geist
 
Status
Nicht offen für weitere Antworten.
Zurück