我遇到了与这个相同的问题,但是我想在<video/>
元素上尝试。
我想通过它的纵横比使视频元素有时width: 100%
,有时height: 100%
。
这是我的css:
.remoteVideo-container {
position: fixed;
left: 0;
top: 0;
z-index: 0;
width: 100vw;
height: 100vh;
text-align: center;
background-color: rgb(45, 48, 53);
}
.remoteVideo {
object-fit: contain;
transform: scale(-1, 1);
}
这是我的 JSX 代码:
<div className="remoteVideo-container">
<video
className="remoteVideo"
autoPlay
ref={this.remoteVideo}
muted
></video>
</div>
Result: