html - 如何将视频和图片放在同一位置?
问题描述
在这里你可以看到两个圆圈分开站立,我怎样才能把它们放在同一个位置
这里两个圆圈的css代码,分别表示position:relative
class .player
,和.player__video
,player1和player2的绝对值,但没有任何改变
.player {
position: relative;
text-align: center;
cursor: pointer;
width: 100%;
height: 100%;
}
@media (max-width: 767px) {
.player {
overflow: hidden;
}
}
.player1{
position: absolute;
text-align: center;
cursor: pointer;
width: 100%;
height: 100%;
}
.player__video {
overflow: hidden;
max-width: 100%;
position: relative;
vertical-align: top;
height: 100%;
width: 100%;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
}
@media screen and (max-width: 600px){
.player__video{
display:none;
}
}
.player2
{
overflow: absolute;
max-width: 100%;
position: absolute;
vertical-align: top;
height: 100%;
width: 100%;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
}
@media (min-width: 768px) {
.player__video, .player2 {
border-radius: 50%;
}
}
.player__video{
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
max-height: 100%;
position: relative;
}
.player2 {
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
max-height: 100%;
}
我应该在这段代码中改变什么?
这里的html代码:
<div class="hero__player">
<div class="player">
<video class="player__video" width="506" height="506" muted preload="auto">
<source src="[xfvalue_videopath]" type="video/mp4">
Your browser does not support the video tag.
</video>
<div class= "player1">
<img class="player2" src=[xfvalue_videopathimage] width="506" height="506">
</div>
</div>
</div>
在HTML代码中我创建了一个player
类,里面有两个类,分别负责图片和视频
解决方案
您可以将它们放在彼此之上postition: absolute
img {
position: absolute;
}
/* Places the last image a off to show they are on top of each other */
img:nth-child(2) {
left: 20px;
top: 20px;
}
<img src="https://placekitten.com/400/400" alt="">
<img src="https://placekitten.com/400/400" alt="">
您可以使用z-index
允许点击到达播放器按钮。
希望这个对你有帮助。
推荐阅读
- sql - ORDER BY 通过表 IMPALA 之间
- android - PWA 用户选择承诺永远不会解决
- amazon-web-services - Cloud9 上的 AWS lambda 和 codecommit
- ruby-on-rails - 覆盖 activerecord 回调以异步运行它们
- angular - 主页中的导航在角度 2 中不起作用
- reactjs - React Bootstrap - DropdownButton 不起作用
- azure - Azure 时间点还原 - 用于检查进度的查询
- docker - 在 apache nifi docker 映像中使用外部库运行 python 脚本
- sql - 列出数量最多的不同行
- java - 按特定逻辑合并 ArrayList of Integers