깃허브: https://github.com/wusi-hub/Youtube-Mobile
구현할 유튜브 모바일과 데스크탑
전체 레이아웃: 헤더, 비디오 플레이어, 비디오 정보란, 재생될 목록란
비디오 정보란: 비디오 메타 데이터, 액션 버튼, 채널 정보
비디오 메타 데이터: 해시 태그, 타이틀, 토글 버튼, 조회수와 올린 날짜
액션 버튼: 버튼 5개
채널 정보: 채널 이미지, 채널 이름, 구독 버튼
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="shortcut icon"
href="https://www.youtube.com/s/desktop/a7767b34/img/favicon.ico"
type="image/x-icon"
/>
<link rel="stylesheet" href="styles.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap"
rel="stylesheet"
/>
<title>
Mother Nature | Mother Nature (sometimes known as Mother Earth or the
Earth Mother) is a personification of nature that focuses on the
life-giving and nurturing aspects of nature by embodying it, in the form
of the mother
</title>
<script
src="https://kit.fontawesome.com/6478f529f2.js"
crossorigin="anonymous">
</script>
<script src="main.js" defer></script>
</head>
<body>
<header>
</header>
<section class="player">
</section>
<div class="infoAndUpNext">
<section class="info"></section>
<section class="upNect"></section>
</div>
</body>
<header>
<div class="logo">
<i class="fab fa-youtube"></i>
<span class="title">Premium</span>
</div>
<div class="icons">
<i class="fas fa-search"></i>
<i class="fas fa-ellipsis-v"></i>
</div>
</header>
<section class="player">
<video controls src="video/video.mp4"></video>
</section>
<div class="infoAndUpNext">
) 안에 넣는다.<div class="infoAndUpNext">
<section class="info">
<div class="metadata"></div>
<ul class="actions"></ul>
<div class="channel"></div>
</section>
<div class="metadata">
<ul class="hashtags"></ul>
<div class="titleAndButton"></div>
<div class="views"></div>
</div>
<div class="metadata">
<ul class="hashtags">
<li>#World</li>
<li>#MotherNature</li>
<li>#Phillip</li>
</ul>
<div class="titleAndButton">
<span class="title clamp">
Mother Nature | Mother Nature (sometimes known as Mother Earth or
the Earth Mother) is a personification of nature that focuses on
the life-giving and nurturing aspects of nature by embodying it,
in the form of the mother
</span>
<button class="moreBtn">
<i class="fas fa-caret-down"></i>
</button>
</div>
<span class="views">1M views 1 month ago</span>
</div>
<ul class="actions">
<li>
<button><i class="active fas fa-thumbs-up"></i><span>1K</span></button>
</li>
<li>
<button><i class="fas fa-thumbs-down"></i><span>0</span></button>
</li>
<li>
<button><i class="fas fa-share"></i><span>Share</span></button>
</li>
<li>
<button><i class="fas fa-plus"></i><span>Save</span></button>
</li>
<li>
<button><i class="fab fa-font-awesome-flag"></i><span>Report</span></button>
</li>
</ul>
<div class="channel">
<div class="metadata">
<img src="image/avatar.jpeg" alt="" />
<div class="info">
<span class="name">WUSI</span>
<span class="subscribers">1M subscribers</span>
</div>
</div>
<button class="subscribe">subscribe</button>
</div>
</section>
<section class="upNext">
<span class="title">Up next</span>
<ul>
<li class="item">
<div class="img"><img src="image/1.jpg" alt="" /></div>
<div class="info">
<span class="title"
>Aurora | An aurora also commonly known as the polar
lights</span
>
<span class="name">WUSI</span>
<span class="views">80K views</span>
</div>
<button class="moreBtn"><i class="fas fa-ellipsis-v"></i></button>
</li>
<li class="item">
<div class="img"><img src="image/2.jpg" alt="" /></div>
<div class="info">
<span class="title"
>Space | Space is the boundless three-dimensional extent</span
>
<span class="name">WUSI</span>
<span class="views">81K views</span>
</div>
<button class="moreBtn"><i class="fas fa-ellipsis-v"></i></button>
</li>
<li class="item">
<div class="img"><img src="image/3.jpg" alt="" /></div>
<div class="info">
<span class="title"
>Forest | A forest is an area of land dominated by trees</span
>
<span class="name">WUSI</span>
<span class="views">82K views</span>
</div>
<button class="moreBtn"><i class="fas fa-ellipsis-v"></i></button>
</li>
</ul>
</section>
</div>
</body>
:root {
/* Color */
--white-color: #fff;
--black-color: #140a00;
--blue-color: #045fd4;
--red-color: #ff0000;
--grey-dark-color: #909090;
--grey-light: #e0e0e0;
/* Size */
--padding: 12px;
--avatar-size: 36px;
/* Font Size */
--font-large: 18px;
--font-medium: 14px;
--font-small: 12px;
--font-micro: 10px;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
}
list-style: none;
을 이용해서 점모양을 없앤다.ul {
list-style: none;
}
button,
button:focus {
border: none;
cursor: pointer;
outline: none;
background-color: transparent;
}
header {
display: flex;
justify-content: space-between;
padding: var(--padding);
background-color: var(--black-color);
color: var(--white-color);
}
header .logo {
font-size: var(--font-large);
}
header .logo i {
color: var(--red-color);
}
header .icons .fa-search {
margin-right: var(--padding);
}
.player {
position: sticky;
top: 0;
text-align: center;
background-color: var(--black-color);
}
.player video {
width: 100%;
height: 100%;
max-width: 1000px;
}
body > .info {
padding: var(--padding);
}
.infoAndUpNext
바로 밑에 있는 info 클래스에 패딩을 넣어준다..infoAndUpNext > .info {
padding: var(--padding);
}
.info .metadata .hashtags {
display: flex;
font-size: var(--font-small);
color: var(--blue-color);
}
.info .metadata .hashtags li {
margin-right: var(--padding);
}
.titleAndButton
을 플렉스 박스로 만든다..info .metadata .titleAndButton {
display: flex;
}
.info .metadata .titleAndButton .title {
font-size: var(--font-medium);
margin-right: var(--padding);
}
.info .metadata .titleAndButton .title.clamp {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.info .metadata .titleAndButton .moreBtn {
height: 100%;
}
.info .metadata .titleAndButton .moreBtn.clicked {
transform: rotate(180deg);
}
.info .views {
font-size: var(--font-small);
color: var(--grey-dark-color);
}
.actions
와 더불어 .info
를 함께 넣어준다..action
을 플렉스 박스로 만든다..action
자체가 너무 붙어있어서 마진을 통해 간격을 만들어준다..info .actions {
display: flex;
justify-content: space-around;
margin: var(--padding) 0;
}
.info .actions button {
display: flex;
flex-direction: column;
font-size: var(--font-small);
color: var(--grey-dark-color);
}
calc()
함수를 이용한다..info .actions button i {
margin: 0 auto;
margin-bottom: calc(var(--padding) / 2);
font-size: 16px;
}
.info .actions button i.active {
color: var(--blue-color);
}
.channel {
display: flex;
padding: 5px;
justify-content: space-between;
border-top: 1px solid var(--grey-light);
border-bottom: 1px solid var(--grey-light);
}
.channel .metadata {
display: flex;
align-items: center;
}
.channel .metadata img {
width: var(--avatar-size);
height: var(--avatar-size);
border-radius: 50%;
}
.channel .metadata .info {
display: flex;
flex-direction: column;
}
.channel .metadata .info .name {
font-size: var(--font-medium);
}
.channel .metadata .info .subscribers {
font-size: var(--font-small);
color: var(--grey-dark-color);
}
.channel .subscribe {
text-transform: uppercase;
color: var(--red-color);
font-size: var(--font-medium);
}
.upNext {
padding-left: var(--padding);
}
calc()
함수를 이용한다..upNext > .title {
font-size: var(--font-medium);
color: var(--grey-dark-color);
margin-bottom: calc(var(--padding) / 2);
}
.upNext .item {
display: flex;
margin-top: var(--padding);
}
.upNext .item .img {
flex: 1 1 15%;
margin-right: var(--padding);
}
.upNext .item .img img {
width: 168px;
height: 94px;
}
.upNext .item .info {
flex: 1 1 80%;
}
.upNext .item .moreBtn {
height: 100%;
flex: 1 1 5%;
}
.upNext .item .info {
display: flex;
flex-direction: column;
}
.upNext .item .info .name {
font-size: var(--font-small);
color: var(--grey-dark-color);
}
.upNext .item .info .views {
font-size: var(--font-micro);
color: var(--grey-dark-color);
}
.infoAndUpNext {
display: flex;
flex-direction: column;
}
.infoAndUpNext
의 값을 지정한다.@media screen and (min-width: 768px) {
.infoAndUpNext {
flex-direction: row;
margin: var(--padding) 0;
}
}
const moreBtn = document.querySelector('.info .metadata .moreBtn');
const title = document.querySelector('.info .metadata .title');
moreBtn.addEventListener('click', () => {
moreBtn.classList.toggle('clicked');
title.classList.toggle('clamp');
});