html - How to set canvas in div with center align of screen -
i have 3 div(div 1, div 2, div 3) , canvas in div. want set #canvasdiv
in div 2. have tried #canvasdiv
id sleep down , div 1 & div 3 placed upper side.
i want set div in 1 line canvas div should in div 2(center).
please see fiddle -
https://jsfiddle.net/8mm2bc2b/2/
thanks in advance.
you can following way: use vertical-align:top
div1
, div3
not go down. , put canvas div inside div2.
#canvasdiv { width: 300px; height:200px; margin: 0px auto; }
<div style="text-align:center;"> <div style="border:1px solid #000; display:inline-block;height:200px; vertical-align: top;">div 1</div> <div style="border:1px solid red; display:inline-block;height:200px; width:300px;">div 2 <div id="canvasdiv" > <canvas id="mycanvas" style="border:1px solid #000000;"></canvas> </div> </div> <div style="border:1px solid red; display:inline-block;height:200px;vertical-align: top;">div 3</div> </div> <br/>
check fiddle here.
Comments
Post a Comment