Próbowałem zrobić skrypt, który by dopasowywał rozmiar diva do rozmiaru okna.
Nie mogę zrobić tego w % czy emach za pomocą JS. Musi być to wyliczane za pomocą JS, ponieważ pewna część strony ma sztywną szerokość...Bywa
I niby wszystko byłoby ladnie i pięknie, ale niestety - nie działa w IE [czemu mnie to nie dziwi ]
Kod: Zaznacz cały
function getWindowHeight() {
if (window.self && self.innerHeight) {
return self.innerHeight;
}
if (document.documentElement && document.documentElement.clientHeight) {
return document.documentElement.clientHeight;
}
return 0;
}
function getWindowWidth() {
if (self.innerWidth) {
return self.innerWidth;
}
if (document.documentElement && document.documentElement.clientWidth) {
return document.documentElement.clientWidth;
}
return 0;
}
function changeSize() {
var offsetTop = 152;
var offsetLeft = 225; // logo and main manu
var elem = document.getElementById("ok"); // left menu
var height = getWindowHeight() - offsetTop - 10; // ustal nowa wysokosc
var width = getWindowWidth() - offsetLeft - 10;
var min_size = 350;
if (height >= min_size) {
elem.style.height = height// + "px"; // set height
}
else {
elem.style.height = min_size// + "px"; // set height
}
if (width >= min_size) {
elem.style.width = width// + "px"; // set width
}
else {
elem.style.width = min_size// + "px"; // set height
}
}
window.onload = changeSize;PS. Nie może być wykonane w CSS. MUSI być za pomocą JS. [chyba, że jest ktoś w stanie podać taki kod, CSS który BEZ ingerencji w kod XHTML pozwoli uzyskać elastyczny pojemnik o rozmiarach width: 100%-230px, height: 100%-160px;]
