resize and center elements

This commit is contained in:
Davide Alberani 2019-11-01 21:25:12 +01:00
parent 98b974621f
commit 9814cc2f81
3 changed files with 16 additions and 12 deletions

View file

@ -1,8 +1,10 @@
#canvas-container { #canvas-container {
min-width: 640px; min-width: 640px;
min-height: 480px; min-height: 480px;
width: 800px;
height: auto;
position: relative; position: relative;
display: none; margin: 0 auto;
} }
#header { #header {
@ -10,18 +12,20 @@
} }
#sb-video { #sb-video {
z-index: 100;
position: absolute; position: absolute;
width: 100%;
height: auto;
top: 0px; top: 0px;
left: 0px; left: 0px;
z-index: 100;
} }
#sb-canvas { #sb-canvas {
z-index: 1000;
position: absolute; position: absolute;
background-color: rgba(0, 0, 0, 0);
top: 0px; top: 0px;
left: 0px; left: 0px;
background-color: rgba(0, 0, 0, 0);
z-index: 1000;
} }
#sb-message { #sb-message {
@ -29,10 +33,3 @@
z-index: 10000; z-index: 10000;
} }
#sb-countdown {
min-width: 20px;
}
.btn {
margin-right: 10px;
}

View file

@ -36,7 +36,7 @@
<div class="row center-align"> <div class="row center-align">
<div id="canvas-container"> <div id="canvas-container">
<video id="sb-video" autoplay="true" muted="muted"></video> <video id="sb-video" autoplay muted></video>
<canvas id="sb-canvas"></canvas> <canvas id="sb-canvas"></canvas>
</div> </div>
</div> </div>

View file

@ -99,6 +99,7 @@ function runCamera(stream) {
video.play(); video.play();
}; };
video.srcObject = stream; video.srcObject = stream;
resizeCanvas(video, 'sb-canvas');
} }
@ -306,3 +307,9 @@ function initCamera() {
}); });
} }
function resizeCanvas(el, canvasID) {
var canvas = document.getElementById(canvasID);
canvas.width = el.offsetWidth;
canvas.height = el.offsetHeighth;
}