When using React, I encountered an issue with centering a webcam video while maintaining its height at 100% of the screen. Although the video fills the screen vertically correctly, adjusting the width of the window causes the video to lose its centered position.
return (
<div style={style.container}>
<video style={style.video}
ref={this.videoRef}
autoPlay={true}></video>
</div>
)
const style = {
container: {
position: 'absolute',
width: '100%',
height: '100%',
overflow: 'hidden',
},
video: {
transform: 'rotateY(180deg)',
height: '100%',
objectFit: 'contain',
objectPosition: 'center'
}
}
Currently, the video is aligned along the left side of the window, rather than staying centered as desired.