Day 39. 트위치 상단 영역

SUN·2021년 8월 19일

08월 19일

학습 내용

사전 작업

CSS

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;}

html, body {
	width: 100%;
	height: 100%;}

body {
	background-color: #0e0e10;}

ol, ul {
	list-style: none;}

a {
 	text-decoration: none;}

img {
	vertical-align: top;}

input {
	outline: none;
	border: none;}

button {
	outline: none;
	border: none;
	background: transparent;}

h1, h2, h3, h4,h5, h6, p, span, input, button, a {
	color: #ffffff;}

.btn-purple {
	background-color: #9147ff;
	color: #ffffff;}

.font-purple {
	color: #9147ff;}
    
 - 트위치가 다크모드이므로 배경색에 맞는 글자색을 적용

트위치 상단

HTMl

<nav>
	<div class="nav-wrap">
		<div class="nav-left">
			<h1 class="logo">
				<a href="#"><img src="https://via.placeholder.com/24px*28px"></a>
			</h1>

			<ul>
				<li><a href="#">탐색</a></li>
				<li><a href="#">이스포츠</a></li>
				<li><a href="#">음악</a></li>
			</ul>
			<div class="more">
				<a href="#">더보기</a>
			</div>

		</div>

		<div class="nav-center">

			<div class="search-wrap">
				<input type="text" placeholder="검색">
				<button class="btn-search"></button>
			</div>
			
		</div>

		<div class="nav-right">
			
			<div class="mark-wrap">
				<i class="icon-mark"></i>
				<span class="alarm">44</span>
			</div>
			<a href="#" class="btn-login">로그인</a>
			<a href="#" class="btn-purple">회원가입</a>
			<button class="btn-profile"></button>

		</div>

	</div>
</nav>

CSS

#top-nav {
	position: fixed;
	width: 100%;
	/* fixed를 적용하면 width값도 같이 적용해야한다. */
	height: 50px;
	background-color: #0e0e10;
	padding: 0 15px;
    - 좌우 간격 설정}

#top-nav .nav-wrap {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;}

#top-nav .nav-wrap .nav-left {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	align-items: center;}


#top-nav .nav-wrap .nav-left .logo img {
	width: 24px;
	height: 28px;}


#top-nav .nav-wrap .nav-left ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	align-items: center;}

#top-nav .nav-wrap .nav-left ul li {
	height: 50px;
	font-size: 20px;
	padding: 0 20px;}

#top-nav .nav-wrap .nav-left ul li a {
	display: block;
	width: 100%;
	height: 100%;
	line-height: 50px;}


#top-nav .nav-wrap .nav-left ul li:first-child {
	padding-right: 0;}

#top-nav .nav-wrap .nav-left ul li:first-child a:after {
	position: relative;

	content: '';
	display: inline-block;
	width: 1px;
	height: 30px;
	background-color: grey;

	margin-left: 20px;
	top: 8px;}
    - 앞의 줄을 만들어주고 relative를 통해 위치 조정


#top-nav .nav-wrap .nav-left .more a {
	display: block;
	height: 50px;
	font-size: 20px;

	line-height: 50px;
	padding-left: 20px;}


#top-nav .nav-wrap .nav-center {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	/* flex의 영향을 받지 않고 화면 가운데로 배치 */}

#top-nav .nav-wrap .nav-center .search-wrap {
	width: 380px;
	height: 36px;
	overflow: hidden;
	border-radius: 5px;

	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;}

#top-nav .nav-wrap .nav-center .search-wrap input {
	width: calc(100% - 34px);
	height: 100%;
	background-color: grey;

	padding: 5px;}

#top-nav .nav-wrap .nav-center .search-wrap .btn-search {
	width: 34px;
	height: 100%;
	background-color: darkgrey;}



#top-nav .nav-wrap .nav-right {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;}

#top-nav .nav-wrap .nav-right .mark-wrap {
	position: relative;}

#top-nav .nav-wrap .nav-right .mark-wrap .icon-mark {
	display: block;
	width: 20px;
	height: 20px;
	background-color: yellow;

	cursor: pointer;}

#top-nav .nav-wrap .nav-right .mark-wrap .alarm {
	position: absolute;
	border-radius: 15px;
	font-size: 14px;
	background-color: red;
	color: #ffffff;

	padding: 2px 8px 2px;

	top: -12px;
	right: -20px;}

#top-nav .nav-wrap .nav-right .btn-login {
	margin-left: 25px;

	width: 53px;
	height: 30px;
	background-color: grey;
	text-align: center;
	line-height: 30px;
	font-size: 12px;
	border-radius: 5px;}

#top-nav .nav-wrap .nav-right .btn-purple {
	margin-left: 10px;

	width: 53px;
	height: 30px;
	text-align: center;
	line-height: 30px;
	font-size: 12px;
	border-radius: 5px;}

#top-nav .nav-wrap .nav-right .btn-profile {
	cursor: pointer;

	margin-left: 10px;

	width: 20px;
	height: 20px;
	background-color: #ffffff;}

학습 중 어려웠던 점

어려운 점은 딱히 없었다.

해결방안

강의 집중해서 듣기

학습 소감

flex를 설정했어도 무시하고 위치를 다시 설정할 수 있다는 것이 감명깊었다.

profile
안녕하세요!

0개의 댓글