8月19日Velog


学習の内容

Twitch実習


https://www.twitch.tv/

0. Default


[css]
* {
	margin: 0;
	padding: 0;

	box-sizing: border-box;
}

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

ol, ul {
	list-style: none;
}

a {
	text-decoration: none;
}

img {
	vertical-align: top;
}

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

h1, h2, h3, h4, h5, h6, p ,span, input, button, a {
	color: #000000;
}
	
body {
	background-color: #f7f7f8;
}



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

.font_purple {
	color: #9147ff;
}

.container {
	width: 100%;
	min-width: 1340px;
	/*더이상 브라우저를 줄일 수 없는 지점*/
}

1. Top nav


こうぞう


[html]
	<nav id="top_nav">
		<div class="nav_wrap">


			<div class="nav_left"></div>
			<div class="nav_center"></div>
			<div class="nav_right"></div>


		</div>
	</nav>
[css]
#top_nav {
	position: fixed;

	width: 100%;
	height: 50px;
	background-color: #ffffff;
	border-bottom: solid 2px #DDDDDE;
	box-sizing: initial;

	z-index: 99999;
}

#top_nav .nav_wrap {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
}
  • #top navにスクロールするときに上部固定css
  • を適用する.

    (1) nav left


    [html]
    			<div class="nav_left">
    				<h1 class="logo">
    					<a href="#">
    						<img src="https://via.placeholder.com/24x28">
    					</a>
    				</h1>
    
    				<ul>
    					<li><a href="#">탐색</a></li>
    					<li><a href="#">e스포츠</a></li>
    					<li><a href="#">음악</a></li>
    				</ul>
    
    				<div class="more">
    					<span>더보기</span>
    				</div>
    			</div>
    [css]
    #top_nav .nav_wrap .nav_left {
    	display: flex;
    	flex-wrap: wrap;
    	justify-content: flex-start;
    	align-items: center;
    }
    
    #top_nav .nav_left .logo {
    	width: 50px;
    	height: 50px;
    
    	padding:  5px;
    }
    
    #top_nav .nav_left .logo a {
    	display: inline-block;
    	width: 100%;
    	height: 100%;
    
    	text-align: center;
    
    }
    
    #top_nav .nav_left .logo a img {
    	width: 24px;
    	height: 28px;
    
    	vertical-align: middle;
    }
    
    #top_nav .nav_left ul {
    	display: flex;
    	flex-wrap: wrap;
    	justify-content: flex-start;
    	align-items: center;
    }
    
    #top_nav .nav_left ul li {
    	padding: 0 20px;
    	height: 50px;
    
    	font-size: 18px;
    	font-weight: 600;
    }
    
    #top_nav .nav_left ul li:first-child a:after {
    	content: "";
    	display: inline-block;
    	width: 1px;
    	height: 30px;
    	background-color: rgba(0,0,0,.1);
    
    	margin-left: 20px;
    
    	position: relative;
    	top: 8px;
    }
    
    #top_nav .nav_left ul li:first-child {
    	padding-right: 0;
    }
    
    
    #top_nav .nav_left ul li a {
    	display: inline-block;
    	width: 100%;
    	height: 100%;
    
    	line-height: 50px;
    }
    
    #top_nav .nav_left .more {
    	padding: 0 10px;
    	height: 50px;
    }
    
    #top_nav .nav_left .more span {
    	display: inline-block;
    
    	font-size: 18px;
    	line-height: 50px;
    }

    (2) nav center


    [html]
    			<div class="nav_center">
    				<div class="search_wrap">
    					<input type="text" placeholder="검색">
    					<button class="btn_search"></button>
    				</div>
    			</div>
    [css]
    #top_nav .nav_wrap .nav_center {
    	position: absolute;
    	left: 50%;
    	transform: translateX(-50%);
    	/*부모 영역에 지정된 flex의 영향을 받지 않게 된다.*/
    }
    
    #top_nav .nav_center .search_wrap {
    	overflow: hidden;
    
    	width: 380px;
    	height: 36px;
    	border-radius: 6px;
    
    	display: flex;
    	flex-wrap: wrap;
    	justify-content: space-between;
    	align-items: center;	
    }
    
    #top_nav .nav_center .search_wrap input {
    	width: calc(100% - 35px);
    	height: 100%;
    	background-color: #e5e5e5;
    
    	padding: 5px 10px;
    }
    
    #top_nav .nav_center .search_wrap input::placeholder{
    	font-size: 14px;
    }
    
    #top_nav .nav_center .search_wrap .btn_search {
    	width: 34px;
    	height: 100%;
    	background-color: #f9f9f9;
    	border: none;
    }

    (3) nav right


    [html]
    			<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 type="button" class="btn_profile"></button>
    			</div>
    [css]
    #top_nav .nav_wrap .nav_right {
    	margin-right: 15px;
    
    	display: flex;
    	flex-wrap: wrap;
    	justify-content: flex-end;
    	align-items: center;
    }
    
    #top_nav .nav_right .mark_wrap {
    	position: relative;
    }
    
    #top_nav .nav_right .mark_wrap .icon_mark {
    	display: block;
    
    	width: 20px;
    	height: 20px;
    	background-color: black;
    
    	cursor: pointer;
    }
    
    #top_nav .nav_right .mark_wrap .alarm {
    	position: absolute;
    
    	background-color: red;
    	border-radius: 15px;
    
    	padding: 0 6px;
    
    	color: #ffffff;
    	font-size: 12px;
    
    	top: -6px;
    	right: -8px;
    
    }
    
    #top_nav .nav_right .btn_login {
    	display: inline-block;
    
    	width: 59px;
    	height: 30px;
    	background-color: #e5e5e5;
    	border-radius: 4px;
    
    	font-size: 12px;
    	font-weight: 600;
    
    	text-align: center;
    	line-height: 30px;
    
    	margin-left: 20px;
    }
    
    #top_nav .nav_right .btn_purple {
    	display: inline-block;
    
    	width: 72px;
    	height: 30px;
    
    	font-size: 12px;
    	font-weight: 600;
    	border-radius: 4px;
    
    	text-align: center;
    	line-height: 30px;
    
    	margin-left: 10px;
    }
    
    #top_nav .nav_right .btn_profile {
    	width: 20px;
    	height: 20px;
    	background-color: black;
    	border-radius: 4px;
    
    	cursor: pointer;
    
    	margin-left: 15px;
    }

    その他の学習内容
  • x軸並べ替え式復習
  • 	left: 50%;
    	transform: translateX(-50%);

  • Emまたはremの値は約10を乗じてpxとして使用され、あまり差がないように見えます...

  • プレースホルダの場所の指定
    :x軸位置はpaddingまたはtext-alignをinputに適用することで変更できます.
    :y軸の位置を中央に揃えたいのですが、まだ方法が見つかりません...