javascript - Resize canvas based on number of canvas wrt to parent div -
i have viewport of dimension. currently, showing single image drawn on html5 canvas. need show multiple canvas range 1-6. requirement resize canvases based on number of canvas fits parent div.
for example : single canvas should take 100% of parent div, 2 canvas 50-50%. 6 canvas 2 rows 3 canvas each.
also, user can toggle show/hide of canvas have rearrange.
how can go doing this? using angularjs ,javascript , html5 css3.
check out css flexbox can auto-size , auto-arrange multiple canvases inside container div.
css-tricks has excellent overview of flexbox
wes bos has done nice series of video tutorials of flexbox
flexbox easy use after small learning curve.
declare div flexbox container:
#thediv{ display: flex; }
and tell flexbox how want canvas-items displayed:
#thediv{ flex-flow: row wrap; }
you haven't detailed how want canvases grow / shrink when container div resized or when user hides / shows canvases, flexbox has grow / shrink settings can apply canvas-items , specific canvas(s).
Comments
Post a Comment