CSS question ?
-
Hi. I have a DIV tag . I want to fix maximum height of it with height of the browser (FF or IE) how can I do it ?
You can do it with Javascript: function setHeight(id) //id is the ID of the div { var d = document.getElementById(id); d.style.position = "absolute"; d.style.height = document.body.clientHeight; } --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentation -
You can do it with Javascript: function setHeight(id) //id is the ID of the div { var d = document.getElementById(id); d.style.position = "absolute"; d.style.height = document.body.clientHeight; } --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentationThank you. I tested your function, but it just return zero (0) :confused:
function setHeight()
{
var d = document.getElementById('main');
d.style.position = "absolute";
d.style.height = document.body.clientHeight;
alert(document.body.clientHeight);
} -
Thank you DJ. I tested it. But it wasn't thing that I wanted. :(
Sorry, misread your question, thought you meant set a maximum height on the div rather than div to maximum height of window. html { height: 100%; } body { min-height: 100%; height: 100%; } div { height: 100%; min-height: 100%; } (div would be given name of your div) This might work, again not 100% sure. TF
-
Thank you. I tested your function, but it just return zero (0) :confused:
function setHeight()
{
var d = document.getElementById('main');
d.style.position = "absolute";
d.style.height = document.body.clientHeight;
alert(document.body.clientHeight);
}It should work.. I tested it in Opera and IE. Where are you calling the function from? Because in IE it's a bit awkward, I think you have to call it on the onLoad() handler or after it or something.. --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentation -
It should work.. I tested it in Opera and IE. Where are you calling the function from? Because in IE it's a bit awkward, I think you have to call it on the onLoad() handler or after it or something.. --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentationI tested in FF3 and IE6. I call it on the onLoad handler.
-
Sorry, misread your question, thought you meant set a maximum height on the div rather than div to maximum height of window. html { height: 100%; } body { min-height: 100%; height: 100%; } div { height: 100%; min-height: 100%; } (div would be given name of your div) This might work, again not 100% sure. TF
Wow. thank you very much. but it doesn't work in IE6. :(
-
Wow. thank you very much. but it doesn't work in IE6. :(
sadly cant test in ie6, dont have it installed, only ie7 :( it does however work fine in ie7 if thats any help :) TF
-
sadly cant test in ie6, dont have it installed, only ie7 :( it does however work fine in ie7 if thats any help :) TF
However thank you my friend.
-
I tested in FF3 and IE6. I call it on the onLoad handler.
You can also use document.body.offsetHeight, however this will only return the browser client height if there is no vertical scrolling on the page, and if you dont want the DIV to be larger than the client height of the browser just assign this to a variable on the onLoad handler and use it afterwards? Also, try out IE 7 - document.body.clientHeight worked fine for me there. Hope this helps, --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentation -
You can also use document.body.offsetHeight, however this will only return the browser client height if there is no vertical scrolling on the page, and if you dont want the DIV to be larger than the client height of the browser just assign this to a variable on the onLoad handler and use it afterwards? Also, try out IE 7 - document.body.clientHeight worked fine for me there. Hope this helps, --Perspx
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentationThank you .