我在我的应用程序中使用https://www.npmjs.com/package/opentok-react并在div中创建发布者和订阅者。这是css:
#videos {
position: fixed;
right: 0;
bottom: 0;
width: auto;
height: auto;
z-index: -100;
min-width: 100%;
min-height: 100%;
overflow: hidden;
//min-height: 720px;
//margin-left: auto;
//margin-right: auto;
}
#subscriber {
position: relative;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 10;
}
#publisher {
position: absolute;
width: 360px;
height: 240px;
bottom: 10px;
right: 10px;
z-index: 100;
border: 3px solid white;
border-radius: 3px;
}
问题是,当我通过订阅组件时,它不遵守道具width 100%
和height 100%
,它没有按照我的预期行事。我希望它使用#subscriber id选择器使用div的完整高度和widdth。但事实并非如此。相反,如果我将道具作为px值传递它是有效的。如何根据百分比使订阅者视频组件符合容器div的大小?
TokBox Developer Evangelist在这里。
在创建发布者和订阅者时,Opentok-React库会将OTPublisherContainer
和OTSubscriberContainer
类分配给DOM元素,因此请分别使用它们为发布者和订阅者设置样式。你可以在这里的库代码中看到这个:
我也继续前进并提交了issue on the repo来改进样式文档。