초심자로서 HTML과 CSS를 마스터하기 위해 한 프로젝트 1개!
HTML:
<body>
<div class="app__videos">
<!-- video starts -->
<div class="video">
<video class="video__player" src="video1.mp4"></video>
<!-- sidebar -->
<div class="videoSidebar">
<div class="videoSidebar__button">
<span class="material-icons"> favorite_border </span>
<p>12</p>
</div>
<div class="videoSidebar__button">
<span class="material-icons"> message </span>
<p>23</p>
</div>
<div class="videoSidebar__button">
<span class="material-icons"> share </span>
<p>75</p>
</div>
</div>
<!-- footer -->
<div class="videoFooter">
<div class="videoFooter__text">
<h3>Harinivas P</h3>
<p class="videoFooter__description">Best Video Ever</p>
<div class="videoFooter__ticker">
<span class="material-icons videoFooter__icon"> music_note </span>
<marquee>Song name</marquee>
</div>
</div>
<img
src="https://static.thenounproject.com/png/934821-200.png"
alt=""
class="videoFooter__record"
/>
</div>
</div>
<!-- video ends -->
<!-- video starts -->
<div class="video">
<video class="video__player" src="video2.mp4"></video>
<!-- sidebar -->
<div class="videoSidebar">
<div class="videoSidebar__button">
<span class="material-icons"> favorite_border </span>
<p>12</p>
</div>
<div class="videoSidebar__button">
<span class="material-icons"> message </span>
<p>23</p>
</div>
<div class="videoSidebar__button">
<span class="material-icons"> share </span>
<p>75</p>
</div>
</div>
<!-- footer -->
<div class="videoFooter">
<div class="videoFooter__text">
<h3>Harinivas P</h3>
<p class="videoFooter__description">Best Video Ever</p>
<div class="videoFooter__ticker">
<span class="material-icons videoFooter__icon"> music_note </span>
<marquee>Song name</marquee>
</div>
</div>
<img
src="https://static.thenounproject.com/png/934821-200.png"
alt=""
class="videoFooter__record"
/>
</div>
</div>
<!-- video ends -->
</div>
<script>
const videos = document.querySelectorAll('video');
for (const video of videos) {
video.addEventListener('click', function () {
console.log('clicked');
if (video.paused) {
video.play();
} else {
video.pause();
}
});
}
</script>
</body>
CSS:
* {
margin: 0;
box-sizing: border-box;
}
html {
scroll-snap-type: y mandatory;
}
body {
color: white;
background-color: black;
height: 100vh;
display: grid;
place-items: center;
}
.app__videos {
position: relative;
height: 750px;
background-color: white;
overflow: scroll;
width: 100%;
max-width: 400px;
scroll-snap-type: y mandatory;
border-radius: 20px;
}
.app__videos::-webkit-scrollbar {
display: none;
}
.app__videos {
-ms-overflow-style: none;
scrollbar-width: none;
}
.video {
position: relative;
height: 100%;
width: 100%;
background-color: white;
scroll-snap-align: start;
}
.video__player {
object-fit: cover;
width: 100%;
height: 100%;
}
.videoSidebar {
position: absolute;
top: 48%;
right: 10px;
}
.videoSidebar .material-icons {
font-size: 28px;
cursor: pointer;
}
.videoSidebar__button {
padding: 20px;
text-align: center;
}
.videoFooter {
position: relative;
bottom: 150px;
margin-left: 20px;
color: white;
display: flex;
}
@keyframes spinTheRecord {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.videoFooter__record {
animation: spinTheRecord infinite 5s linear;
height: 50px;
filter: invert(1);
position: absolute;
bottom: 0;
right: 20px;
}
.videoFooter__text {
flex: 1;
}
.videoFooter__text h3 {
padding-bottom: 20px;
}
.videoFooter__icon {
position: absolute;
}
.videoFooter__ticker {
width: 400px;
display: flex;
align-items: center;
}
.videoFooter__ticker marquee {
height: fit-content;
margin-left: 30px;
width: 60%;
}
.videoFooter__description {
padding-bottom: 20px;
}
@media (max-width: 425px) {
.app__videos {
width: 100%;
height: 100%;
max-width: 100%;
border-radius: 0;
}
}
결과는 다음과 같습니다.
(전체 사진을 찍지 못했습니다. 실제 결과물에서는 가장자리가 휘어져 보입니다.)
전체 코드: Github
코드가 어려워 보일 수 있습니다. 그러나 인내심을 가지고 진행하면 분명히 이해할 수 있을 것입니다. 더 재미있는 프로젝트가 찾아옵니다 :)
Reference
이 문제에 관하여(초심자로서 HTML과 CSS를 마스터하기 위해 한 프로젝트 1개!), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/harinivas/1-project-i-did-to-master-html-and-css-as-a-beginner-2k6f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)