A Pen by Ardeshir Eshghi on CodePen.
Created
March 3, 2021 00:58
-
-
Save ardeshireshghi/7d7e82551b5ff341ae007169bc5d2133 to your computer and use it in GitHub Desktop.
RwoJNNZ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="video-grid js-video-grid"> | |
<div class="video-container"> | |
<video src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4" /> | |
</div> | |
<div class="video-container"> | |
<video src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4" /> | |
</div> | |
<div class="video-container"> | |
<video src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4" /> | |
</div> | |
<div class="video-container"> | |
<video src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4" /> | |
</div> | |
<div class="video-container"> | |
<video src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4" /> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const videoGrid = document.querySelector('.js-video-grid'); | |
videoGrid.addEventListener('mouseover', (event) => { | |
if ( event.target.closest('video')) { | |
event.target.closest('video').play(); | |
console.log(event.target); | |
} | |
}) | |
videoGrid.addEventListener('mouseout', (event) => { | |
if ( event.target.closest('video')) { | |
console.log('OUT', event.target); | |
event.target.closest('video').pause(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.float-grid > * { | |
float: left; | |
width: 25%; | |
} | |
.float-grid:after { | |
clear: both; | |
} | |
.box { | |
height: 100px; | |
position: relative; | |
background: yellow; | |
text-align: center; | |
} | |
/* .box > * { | |
top: 50%; | |
transform: translateY(-50%) translateZ(0); | |
} */ | |
.box--red { | |
background-color: red; | |
} | |
.video-grid { | |
display: grid; | |
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); | |
grid-template-rows: auto; | |
} | |
.video-container { | |
position: relative; | |
padding-bottom: 56.25%; /* 16:9 */ | |
height: 0; | |
} | |
video { | |
width: 100% !important; | |
height: auto !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment