초심자로서 HTML과 CSS를 마스터하기 위해 한 프로젝트 1개!

20571 단어 webdevcssbeginnershtml
HTML과 CSS 태그를 일주일 동안 외운 후 배운 것을 적용하기로 결정했습니다. 그래서 저는 HTML, CSS 및 약간의 Javascript를 사용하여 TikTok 클론을 만들었습니다. HTML 및 CSS 초보자라면 이 블로그가 완벽한 블로그입니다!

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

코드가 어려워 보일 수 있습니다. 그러나 인내심을 가지고 진행하면 분명히 이해할 수 있을 것입니다. 더 재미있는 프로젝트가 찾아옵니다 :)

좋은 웹페이지 즐겨찾기