I am creating an image viewer with a canvas which will pop open in a new window. I would like the canvas to be the width of the window and 100px from the top and bottom. I would also like for it to resize without using javascript (let me handle the redrawing in javascript – I just want to see the canvas stay fixed to the edges of the window with the top and bottom spacing.) How can I do this? I tried the following but the right and bottom are ignored:
.contextCanvas
{
position: fixed;
left: 0px;
right: 0px;
top: 100px;
bottom: 100px;
}
Any suggestions or reasoning as to why the browser will happily ignore the right and bottom?
I found the answer – I had to wrap the canvas in a container div which was fixed positioned and then set the inner canvas to absolute positioning and 100% width & height.
HTML
And here’s the CSS