Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][HTML]Java Script nie chce się połączyć.
Generic
post
Post #1





Grupa: Zarejestrowani
Postów: 224
Pomógł: 0
Dołączył: 31.10.2012

Ostrzeżenie: (10%)
X----


Witam. Robię fullscren tła w html/css/js. Co jest nie tak w poniższym kodzie że nie działa mi tło tak jak powinno. Z góry dziękuję i czekam na odpowiedź. Pozdrawiam.

  1. <img id="bg" src="background.png";base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" style="position: fixed; left: 0; top: 0" />


#bg { position: fixed; top: 0; left: 0; }
.bgwidth { width: 100%; }
.bgheight { height: 100%; }


// JavaScript Document

(function() {

var win = $(window);

win.resize(function() {

var win_w = win.width(),
win_h = win.height(),
$bg = $("#bg");

// Load narrowest background image based on
// viewport width, but never load anything narrower
// that what's already loaded if anything.
var available = [
1024, 1280, 1366,
1400, 1680, 1920,
2560, 3840, 4860
];

var current = $bg.attr('src').match(/([0-9]+)/) ? RegExp.$1 : null;

if (!current || ((current < win_w) && (current < available[available.length - 1]))) {

var chosen = available[available.length - 1];

for (var i=0; i<available.length; i++) {
if (available[i] >= win_w) {
chosen = available[i];
break;
}
}

// Set the new image
$bg.attr('src', 'background.png' + chosen + '.png');

// for testing...
// console.log('Chosen background: ' + chosen);

}

// Determine whether width or height should be 100%
if ((win_w / win_h) < ($bg.width() / $bg.height())) {
$bg.css({height: '100%', width: 'auto'});
} else {
$bg.css({width: '100%', height: 'auto'});
}

}).resize();

})(jQuery);
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
muniekw
post
Post #2





Grupa: Zarejestrowani
Postów: 243
Pomógł: 22
Dołączył: 1.06.2009
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Zobacz np to: Full Screen
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 06:34