HTML 문서
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>네이버</title>
<link rel="stylesheet" type="text/css" href="css/style1.css">
</head>
CSS 문서
/* Default CSS */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
ol, ul {
list-style: none;
}
a {
text-decoration: none;
color: #000000;
}
img {
vertical-align: middle;
}
button {
border: none;
}
input, textarea {
outline: none;
}
.clearfix {
clear: both;
}
.container {
width: 1130px;
margin: 0 auto;
}
flex
속성만을 위한 class
작업을 진행 (각 태그마다 flex
속성을 설정하는 것보다, 별도의 class
를 만들어서 단순화, 코드 분량 절감), 필요한 곳에 class
를 넣으면 됨예) CSS 문서
.news-flex-between {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
.news-flex-start {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.news-flex-end {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
align-items: center;
}
nav
태그는 메뉴 태그이지만, 개발자 스타일마다 변경할 수 있음 (필수가 아님)
a
태그의 width
, height
값이 100% 이면, 해당 영역 전부 손가락 모양으로 바뀜(클릭 영역)
input
태그 사용 시, 입력창 안에 정보를 알려주는 글을 넣을 때는 placeholder
태그 사용
article
태그에는 타이틀 정보가 무조건 필요, h1 ~ h6
태그 중 하나는 필수로 들어가야 함
길이를 설정할 때는 width
, height
값과 margin
값, 그리고 여유 공간 등까지 고려하여 설정
HTML 문서
<!-- 네이버 뉴스 상단 -->
<body>
<header id="news-header">
<div class="news-container">
<div class="news-flex-between">
<nav class="news-header-left">
<ul class="news-flex-start">
<li class="on"><a href="#">뉴스</a></li>
<li><a href="#">TV연예</a></li>
<li><a href="#">스포츠</a></li>
<li><a href="#">뉴스스탠드</a></li>
<li><a href="#">날씨</a></li>
<li><a href="#">프리미엄</a></li>
<li><a href="#">TOKYO 2020</a></li>
</ul>
</nav>
<div class="news-header-right news-flex-end">
<a href="#" class="btn-login">로그인</a>
<button type="button" class="btn-menu"></button>
</div>
</div>
</div>
<nav class="sub-nav">
<div class="news-container">
<div class="news-flex-between">
<ul class="news-flex-start">
<li><a href="#" class="on">뉴스홈</a></li>
<li><a href="#">속보</a></li>
<li><a href="#">정치</a></li>
<li><a href="#">경제</a></li>
<li><a href="#">사회</a></li>
<li><a href="#">생활/문화</a></li>
<li><a href="#">세계</a></li>
<li><a href="#">IT/과학</a></li>
<li><a href="#">오피니언</a></li>
<li><a href="#">포토</a></li>
<li><a href="#">TV</a></li>
<li><a href="#">랭킹뉴스</a></li>
</ul>
<div class="news-search-wrap news-flex-between">
<input type="text" placeholder="뉴스 검색">
<button type="button" class="btn-search"></button>
</div>
</div>
</div>
</nav>
</header>
<div id="news-headline">
<div class="news-container">
<div class="news-headline-menu-wrap news-flex-between">
<ul class="main-lists news-flex-start">
<li><a href="#">신문 헤드라인</a></li>
<li><a href="#">저녁 방송 뉴스</a></li>
</ul>
<ul class="sub-lists news-flex-end">
<li><a href="#">팩트체크</a></li>
<li><a href="#">언론사 설정</a></li>
<li><a href="#">언론사 뉴스</a></li>
<li><a href="#">라이브러리</a></li>
</ul>
</div>
<ul class="news-headline-lists news-flex-between">
<li>
<a href="#">
<article>
<h3>KBS 뉴스9</h3>
<div class="image-wrap">
<img src="https://via.placeholder.com/150">
<div class="overlay">
<div class="headline-info news-flex-start">
<i></i>
<div>
<span>다시보기</span>
<p>신규 최다 확진 또 경신...정부 "거리 두기 효...</p>
</div>
</div>
</div>
</div>
</article>
</a>
</li>
<li>
<a href="#">
<article>
<h3>KBS 뉴스9</h3>
<div class="image-wrap">
<img src="https://via.placeholder.com/150">
<div class="overlay">
<div class="headline-info news-flex-start">
<i></i>
<div>
<span>다시보기</span>
<p>신규 최다 확진 또 경신...정부 "거리 두기 효...</p>
</div>
</div>
</div>
</div>
</article>
</a>
</li>
<li>
<a href="#">
<article>
<h3>KBS 뉴스9</h3>
<div class="image-wrap">
<img src="https://via.placeholder.com/150">
<div class="overlay">
<div class="headline-info news-flex-start">
<i></i>
<div>
<span>다시보기</span>
<p>신규 최다 확진 또 경신...정부 "거리 두기 효...</p>
</div>
</div>
</div>
</div>
</article>
</a>
</li>
<li>
<a href="#">
<article>
<h3>KBS 뉴스9</h3>
<div class="image-wrap">
<img src="https://via.placeholder.com/150">
<div class="overlay">
<div class="headline-info news-flex-start">
<i></i>
<div>
<span>다시보기</span>
<p>신규 최다 확진 또 경신...정부 "거리 두기 효...</p>
</div>
</div>
</div>
</div>
</article>
</a>
</li>
</ul>
<div class="news-headline-arrows news-flex-end">
<div class="btn-wrap news-flex-start">
<a href="#" class="btn btn-prev"></a>
<a href="#" class="btn btn-next"></a>
</div>
<a href="#" class="btn btn-up"></a>
</div>
</div>
</div>
<!-- 네이버 뉴스 메인 -->
<main role="main" id="news-main">
<div class="news-container">
<div class="news-left">
</div>
<div class="news-right">
</div>
</div>
</main>
<body>
CSS 문서 1 - style.css
/* 네이버 뉴스 상단 */
.news-container {
width: 1080px;
margin: 0 auto;
}
.news-flex-between {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}
.news-flex-start {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.news-flex-end {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
align-items: center;
}
#news-header {
background-color: #3f63bf;
}
#news-header .news-header-left {
padding-top: 17px;
padding-bottom: 17px;
}
#news-header .news-header-left ul li {
font-size: 15px;
}
#news-header .news-header-left ul li.on {
font-size: 20px;
}
#news-header .news-header-left ul li a {
color: #ffffff;
}
#news-header .news-header-left ul li a:before {
display: inline-block;
content: '';
width: 1px;
height: 15px;
background-color: #000;
opacity: 0.2;
margin: 0 10px;
vertical-align: -1px;
}
#news-header .news-header-left ul li:first-child a:before {
content: none;
}
#news-header .news-header-right .btn-login {
display: block;
width: 55px;
height: 25px;
border: solid 1px #000000;
line-height: 25px;
text-align: center;
color: #ffffff;
font-size: 12px;
margin-right: 20px;
}
#news-header .news-header-right .btn-menu {
width: 55px;
height: 55px;
background-color: #3f63bf;
border-left: solid 1px #000000;
border-right: solid 1px #000000;
}
#news-header .sub-nav {
background-color: #ffffff;
border-top: solid 1px #000000;
border-bottom: solid 1px #e3e3e3;
}
#news-header .sub-nav ul li {
width: auto;
height: 46px;
margin-right: 16px;
}
#news-header .sub-nav ul li a {
display: block;
width: 100%;
height: 100%;
border-bottom: solid 2px transparent;
font-weight: bold;
line-height: 46px;
}
#news-header .sub-nav ul li a.on {
border-bottom: solid 2px #3f63bf;
color: #3f63bf;
}
#news-header .sub-nav .news-search-wrap {
width: 280px;
height: 30px;
border: solid 1px #e1e1e1;
background-color: #fafafa;
}
#news-header .sub-nav .news-search-wrap input {
width: calc(100% - 30px);
height: 100%;
border: none;
font-size: 12px;
color: #888888;
padding: 3px 9px;
}
#news-header .sub-nav .news-search-wrap input:focus {
outline: none;
}
#news-header .sub-nav .news-search-wrap .btn-search {
width: 30px;
height: 100%;
background-color: blue;
}
#news-headline {
padding-top: 20px;
}
#news-headline .news-container {
border-bottom: solid 1px #000000;
padding-bottom: 12px;
}
#news-headline .news-headline-menu-wrap {
margin-bottom: 15px;
}
#news-headline .news-headline-menu-wrap .main-lists li {
margin-right: 20px;
font-size: 15px;
}
#news-headline .news-headline-menu-wrap .sub-lists li {
font-size: 12px;
}
#news-headline .news-headline-menu-wrap .sub-lists li a:before {
content: '';
display: inline-block;
width: 1px;
height: 12px;
background-color: #e0e0e0;
margin: 0 5px;
vertical-align: -1px;
}
#news-headline .news-headline-menu-wrap .sub-lists li:first-child a:before {
content: none;
}
#news-headline .news-headline-lists {
margin-bottom: 12px;
}
#news-headline .news-headline-lists li {
width: 255px;
height: 178px;
border: solid 1px #ccc;
}
#news-headline .news-headline-lists li a {
display: block;
width: 100%;
height: 100%;
}
#news-headline .news-headline-lists li a article {
position: relative;
width: 100%;
height: 100%;
}
#news-headline .news-headline-lists li a article h3 {
width: 100%;
height: 44px;
line-height: 44px;
text-align: center;
}
#news-headline .news-headline-lists li a article .image-wrap {
position: relative;
width: 100%;
height: 132px;
background-color: pink;
}
#news-headline .news-headline-lists li a article .image-wrap img {
position: absolute;
width: 100%;
height: 100%;
}
#news-headline .news-headline-lists li a article .image-wrap .overlay {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
#news-headline .news-headline-lists li a article .image-wrap .overlay .headline-info {
position: absolute;
width: 100%;
padding: 15px 20px;
left: 0;
bottom: 0;
color: #ffffff;
}
#news-headline .news-headline-lists .headline-info i {
display: block;
width: 26px;
height: 26px;
background-color: black;
border-radius: 50%;
margin-right: 10px;
}
#news-headline .news-headline-lists .headline-info div {
width: calc(100% - 38px);
}
#news-headline .news-headline-lists .headline-info span {
font-size: 13px;
font-weight: bold;
}
#news-headline .news-headline-lists .headline-info p {
display: inline;
font-size: 12px;
}
#news-headline .news-headline-arrows .btn-wrap {
margin-right: 15px;
}
#news-headline .news-headline-arrows .btn {
display: block;
width: 24px;
height: 24px;
border: solid 1px #dcdddc;
}
#news-headline .news-headline-arrows .btn.btn-prev {
background-color: yellow;
border-right: none;
}
#news-headline .news-headline-arrows .btn.btn-next {
background-color: pink;
}
#news-headline .news-headline-arrows .btn.btn-up {
background-color: black;
}
/* 네이버 뉴스 메인 */
#news-main .news-container {
overflow: hidden;
}
#news-main .news-left {
float: left;
width: 750px;
}
#news-main .news-right {
float: right;
width: 327px;
border-left: solid 1px #dfdfdf;
padding: 25px 0 40px 26px;
/* background-color: yellowgreen; */
}