Reputation: 2587
Here is My Demo http://jsfiddle.net/9D4L4/2/
I am using canvas
element for the Image.
The DIV
which contain canvas
Element not taking the Line-height.
I want to make the canvas element verticaly center to the div. Please Help me
HTML
<h1>Normal Image </h1>
<div>
<img src="http://jeevanmukti.info/images/key.gif" />
</div>
<br><br><br>
<h1>When i use canvas </h1>
<div>
<canvas >1111</canvas>
</div>
CSS
div{background:grey; width:100px; height:100px; text-align:center; line-height:100px; }
img{max-width:100%; max-height:100%}
canvas{background:url('http://jeevanmukti.info/images/key.gif') no-repeat center center; padding:0; margin:0; max-width:100%; max-height:100%}
I want the Whole Canvas(in red color) to be the vertically center of that DIV
Upvotes: 0
Views: 732
Reputation: 1917
Giving the canvas a height of 100px will do it, so the canvas will fill the height of the parent DIV
Upvotes: -1