I have html like:
.image-detail { height: 100%; width: 100%; display: block; position: relative; } canvas { display: block; } .image-detail-canvas { -moz-user-select: none; -webkit-user-select: none; max-width: 100% !important; max-height: 100% !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; }
<div class="image-detail"> <canvas class="image-detail-canvas" id="image-canvas"> </canvas> </div>
He centers the canvas, but the canvas is stretched.
I do not want the canvas to be stretched.
I want it to be centered without stretching. If the canvas is horizontally and horizontally, then and so on.
source share