[클론코딩/코코아톡] 노마드 코더 코코아톡 클론코딩 #3 Friends Screen
Friends Screen - Navigation Bar(HTML)
- 단축키
nav>ul>li*4>a → Enter : <nav> 안에 <ul> 안에 <li>4개와 <a> 한번에 생성됨.
- Navigation Bar(HTML)
<!-- Navigation Bar -->
<nav class="nav">
<ul class="nav__list">
<li class="nav__btn">
<a class="nav__link" href="friends.html">
<i class="fas fa-solid fa-user fa-2x"></i>
</a>
</li>
<li class="nav__btn">
<a class="nav__link" href="#">
<span class="nav__notification">1</span>
<i class="fa-regular fa-comment fa-2x"></i>
</a>
</li>
<li class="nav__btn">
<a class="nav__link" href="#">
<i class="fas fa-regular fa-magnifying-glass fa-2x"></i>
</a>
</li>
<li class="nav__btn">
<a class="nav__link" href="#">
<span class="nav__more-notification"></span>
<i class="fas fa-ellipsis-h fa-2x"></i>
</a>
</li>
</ul>
</nav>
<script src="https://kit.fontawesome.com/917b690364.js" crossorigin="anonymous"></script>
</body>
</html>
Friends Screen - Navigation Bar(CSS)
- box-sizing: border-box;
width와 padding을 같이 설정할 경우,
브라우저는 padding을 주고, 입력받은 width를 맞추기 위해 padding만큰 width를 늘리게 됨.
따라서 box 사이즈가 늘어나게 됨.
→ 이러한 현상을 없애기 위해 'box-sizing: border-box;'를 사용함.
'box-sizing: border-box;'은 padding은 상관없으니 box사이즈를 변경하지 말라는 것을 의미함.
- Navigation Bar(CSS)
.nav {
position: fixed;
bottom: 0;
width: 100%;
background-color: #f9f9fa;
padding: 20px 50px;
box-sizing: border-box;
border-top: 1px solid rgba(121, 121, 121, 0.3);
}
.nav__list {
display: flex;
justify-content: space-between;
}
.nav__link {
color: #2e363e;
position: relative;
}
.nav__notification {
background-color: tomato;
width: 26px;
height: 26px;
border-radius: 13px;
display: flex;
justify-content: center;
align-items: center;
color: white;
font-weight: 600;
position: absolute;
left: 20px;
bottom: 15px;
}
.nav__more-notification {
background-color: tomato;
width: 6px;
height: 6px;
border-radius: 3px;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
left: 30px;
bottom: 30px;
}
+ 추가 설명
- .nav
→ navigation-bar 아래에 고정되도록 설정.
- .nav__link
→ .nav__notification / .nav__more-norification에 position: absolute;를 적용하기 위해,
position: relative;를 설정.
(position: absolute;는 가장 가까운 relative 부모를 기준으로 이동하기 때문에,
설정하지 않으면 body를 기준으로 이동함.)
- .nav__notification / .nav__more-norification
→ width와 height를 동일하게 설정하고 border-radius를 width와 height의 반으로 설정하면 원이 그려짐.
- reset.css
모든 link에 적용되도록 reset.css에 추가.
a {
color:inherit;
text-decoration: none;
}
Friends Screen- Status Bar(CSS)
- status-bar가 위에 고정되도록 수정.
.status-bar {
position: fixed;
top: 0;
width: 100%;
display: flex;
justify-content: center;
padding: 5px;
}
Friends Screen - Header(HTML)
<!-- Header -->
<header class="screen-header">
<h1 class="screen-header__title">Friends</h1>
<div class="screen-header__icons">
<span><i class="fa-regular fa-comment fa-lg"></i></span>
<span><i class="fas fa-music fa-lg"></i></span>
<span><i class="fa-solid fa-gear fa-lg"></i></span>
</div>
</header>
Friends Screen- Header(CSS)
- Header는 여러 곳에서 사용되므로 따로 css를 만들어줌.
주의) styles.css에 import를 해야 실행이 됨.
.screen-header {
margin-top: 30px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 25px;
}
.screen-header__title {
font-size: 32px;
font-weight: 600;
}
.screen-header__icons span {
margin-left: 25px;
}
Friends Screen- Friend's Display(HTML, CSS)
- Friend's Display(HTML)
<!-- Friend's Display -->
<a id="friends-display-link"><i class="fas fa-info-circle"></i>Friend's Names Display</a>
- Friend's Display(CSS)
#friends-display-link {
text-align: center;
display: block;
background-color: #fafafa;
padding: 15px 0px;
font-size: 16px;
}
#friends-display-link i {
color: rgba(0, 0, 0, 0.3);
padding: 0px 10px;
}
Friends Screen- User Component(HTML, CSS)
- 여러 곳에서 사용되는 것은 따로 만들어 재사용하는 것이 좋음.
- User Component(HTML) : 나중에 사용할 수 있도록 구현.
<!-- User Component -->
<div class="user-component">
<div class="user-component__column">
<img src="img/user_img.jpg" class="user-component__avatar"/>
<div class="user-component__text">
<h4 class="user-component__title">Smile:)</h4>
<h6 class="user-component__subtitle">Be Happy Don't Worry</h6>
</div>
</div>
<div class="user-component__column"></div>
</div>
- User Component(CSS) : 나중에 사용할 수 있도록 구현.
.user-component,
.user-component__column:first-child {
display: flex;
align-items: center;
}
.user-component__avatar {
width: 70px;
height: 70px;
border-radius: 25px;
margin-right: 15px;
}
.user-component__title {
font-weight: 600;
font-size: 20px;
}
.user-component__subtitle {
margin-top: 5px;
font-size: 14px;
color: rgba(0, 0, 0, 0.5);
}
- User Component(HTML) : Friends Screen에서 사용하도록 수정.
<!-- User Component -->
<main class="friends-screen">
<div class="user-component">
<div class="user-component__column">
<img src="img/user_img.jpg" class="user-component__avatar user-component__avatar--xl"/>
<div class="user-component__text">
<h4 class="user-component__title">Smile:)</h4>
<!-- <h6 class="user-component__subtitle">Be Happy Don't Worry</h6> -->
</div>
</div>
<div class="user-component__column"></div>
</div>
<div class="friends-screen__channel">
<div class="friends-screen__channel-header">
<span>Channel</span>
<i class="fas fa-chevron-up fa-xs"></i>
</div>
<div class="user-component">
<div class="user-component__column">
<img src="img/user_img.jpg" class="user-component__avatar user-component__avatar--sm"/>
<div class="user-component__text">
<h4 class="user-component__title user-component__title--not-bold">Channel</h4>
</div>
</div>
<div class="user-component__column">
<span>2</span>
<i class="fas fa-chevron-right fa-xs"></i>
</div>
</div>
</div>
</div>
</main>
- User Component(CSS) : Friends Screen에서 사용하도록 수정.
.user-component {
justify-content: space-between;
}
.user-component,
.user-component__column:first-child {
display: flex;
align-items: center;
}
.user-component__avatar {
width: 70px;
height: 70px;
border-radius: 25px;
margin-right: 15px;
}
.user-component__title {
font-weight: 600;
font-size: 20px;
}
.user-component__subtitle {
margin-top: 5px;
font-size: 14px;
color: rgba(0, 0, 0, 0.5);
}
.user-component__avatar--xl {
width: 80px;
height: 80px;
border-radius: 30px;
}
.user-component__avatar--sm {
width: 60px;
height: 60px;
border-radius: 20px;
}
.user-component__title--not-bold {
font-weight: 400;
}
.user-component__column:last-child {
color:rgba(0, 0, 0, 0.5);
}
+ 추가 설명
- .user-component__avatar--xl / .user-component__avater--sm
→ 기본으로 설정한 것과 다를 경우, 다른 class를 추가해 상황에 맞게 수정해서 적용.
- friends.css
#friends-display-link {
text-align: center;
display: block;
background-color: #fafafa;
padding: 15px 0px;
font-size: 16px;
margin-bottom: 10px;
}
#friends-display-link i {
color: rgba(0, 0, 0, 0.3);
padding: 0px 10px;
}
.friends-screen {
padding: 0px var(--horizontal-space);
}
.friends-screen__channel {
margin-top: 25px;
border-top: 1px solid rgba(0, 0, 0, 0.2);
padding-top: 15px;
}
.friends-screen__channel-header {
margin-bottom: 30px;
display: flex;
justify-content: space-between;
color:rgba(0, 0, 0, 0.5);
}
+ 추가 설명
- .friends-screen
→ header의 'Friends' text와 간격이 일치하도록 변수로 설정 후 적용.