代码之家  ›  专栏  ›  技术社区  ›  user824624

如何使按钮与顺风垂直和水平居中

  •  1
  • user824624  · 技术社区  · 3 年前

    我想构建一个带有顺风的视频播放器UI,播放按钮应该位于播放器容器的中间。

    enter image description here

    我试着编码,但还是失败了

    <div style="width: 600px;height:300px" class="flex items-center justify-center">
            <button class="w-72 h-72 rounded-full  bg-blue-500 hover:bg-red-500 text-white">
                <i class="el-icon-video-play text-2xl"> </i>
            </button>
            <video id="vid1" width=600 height=300 controls style="width: 100%;height: 100%;" class="video-js vjs-default-skin" preload="auto">
                <source :src="url" type="video/mp4">
            </video>
    </div>
    

    有什么建议吗?

    1 回复  |  直到 3 年前
        1
  •  1
  •   Mahdad    3 年前

    您可以将按钮设置为绝对值,如下所示:

    <button
            class="absolute w-16 h-16 rounded-full bg-blue-500 hover:bg-red-500 text-white">
            <i class="el-icon-video-play text-2xl"> </i>
    </button>