CSS 可以實現(xiàn)視頻循環(huán)播放,以下是實現(xiàn)視頻循環(huán)播放的 CSS 代碼示例:
video { width: 100%; height: auto; } video::-webkit-media-controls-play-button, video::-webkit-media-controls-start-playback-button { display: none!important; } video { pointer-events: none; } video:after { pointer-events: auto; content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: pointer; } video.autoplay { display: block!important; visibility: hidden!important; } video.autoplay:after { display: none!important; } video.loop { pointer-events: none; } video.loop:before { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-image: inherit; background-size: cover; background-position: center center; animation: video-loop 10s linear infinite; } @keyframes video-loop { to { transform: scale(1.1); } }
以上 CSS 代碼可以實現(xiàn)視頻循環(huán)播放的功能,其中 video.autoplay 可以實現(xiàn)視頻自動播放,video.loop 可以實現(xiàn)視頻循環(huán)播放。