Prevents Me From Resizing My
Recently I fall in love with HTML5(especially games), and I realize I should strengthen my JavaScript first, hence, I read Head First JavaScript(O'Reilly) to take a crack. I intend
Solution 1:
When you add <!DOCTYPE html>
, you put the document into standards mode.
There's a couple of changes you need to make to get this working. First, in standards mode, the page is only as high as it needs to be. So document.body.clientHeight
is just the height of your image and a little bit of margin. To make the height of the page match that of the viewport, as happens by default in quirks mode add this CSS:
html, body { height:100% }
Second, in standards mode, you need to state the dimensions you're using when setting style.width and style.height. This is as easy as adding + "px"
to the end of the size setting line, making it
document.getElementById("rock").style.height =
( document.body.clientHeight - 100 ) * 0.9 + "px";
Solution 2:
Most likely <img>
is being inline CSS element and you cannot set height for such elements.
Add:
#rock {
display: block;
}
in your stylesheet.
Moer info
Post a Comment for " Prevents Me From Resizing My "