네이버 모바일 페이지(2), 자바스크립트 변수와 데이터타입(1), (2), 제어문, 전역/지역변수, 스코프, 호이스팅 (1)
<li class="left-list">
<a href="#">
<i class="icon-arrow icon-arrow-left"></i>
<div class="content-wrap">
<div class="txt-wrap">
<h3>패션뷰티판</h3>
<p>온호프 론칭 기념<br>
브랜드 위크
</p>
</div>
<img src="https://via.placeholder.com/52" alt="">
</div>
</a>
</li>
<li class="right-list">
<a href="#">
<div class="content-wrap">
<img src="https://via.placeholder.com/52" alt="">
<div class="txt-wrap">
<h3>킬리만자로의 용자 다간</h3>
<p>그레이트다간 GX 공개<br>
LIVE 중 추가적립
</p>
</div>
</div>
<i class="icon-arrow icon-arrow-right"></i>
</a>
</li>
float
을 사용하였다. 이로 인해 부모가 li의 높이를 인식하지 못하게 되어 ul에 overflow:hidden
을 적용시켜 주었다.#talk ul {
overflow: hidden;
}
#talk ul li.left-list {
float:left;
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
}
#talk ul li.right-list {
float: right;
border-top-left-radius: 40px;
border-bottom-left-radius: 40px;
}
<div class="content-body">
<a class="link-banner" href="#">
<img class="banner" src="https://via.placeholder.com/345x140" alt="">
</a>
<a class="link-txt" href="#">
<div class="bottom-wrap">
<i class="icon"></i>
<div class="txt-wrap">
<h3>네이버 웨일</h3>
<p>내 휴대폰 속 사진을 PC로 쏙!<br>
기기에 관계없이 파일을 그대로 그린드랍
</p>
</div>
</div>
</a>
</div>
border-radius
를 적용해 모서리를 둥글게 만들어주고 overflow:hidden
을 사용해 튀어나가는 부분을 안 보이게 처리해주었다.#today .content-body {
overflow: hidden;
width: 100%;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 1px 6px 0 rgb(0 0 0 / 6%), 0 1px 0 0 rgb(0 0 0 / 2%);
}
#footer .txt-wrap a {
position: relative;
display: inline-block;
padding: 3px 9px;
color: #929294;
font-size: 13px;
font-weight: 400;
letter-spacing: -.5px;
}
#footer .txt-wrap a::before {
content: "";
display: block;
position: absolute;
top: 7px;
left: 0;
width: 1px;
height: 10px;
background-color: #d7dfe7;
}
nth-child()
를 이용하여 선택하려 했으나 <br>
태그로 인해 연속성이 깨져서 잘 선택되지 않았다. 그래서 각 줄을 다시 div태그로 묶은 후 각 영역 안 첫번째 a태그를 선택하는 방식을 사용했다.<div class="txt-wrap">
<div class="link">
<a href="#">로그인</a>
<a href="#">전체서비스</a>
<a href="#">PC버전</a>
</div>
<div class="link">
<a href="#">이용약관</a>
<a href="#">개인정보처리방침</a>
<a href="#">고객센터</a>
</div>
</div>
#footer .txt-wrap .link a:first-child:before {
content: none;
}
<script>
console.log("hi");
</script>
<script src="js/main.js"></script>
==
: 값만 비교해서 같으면 true===
: 값과 데이터터입 둘다 비교해서 같아야 truetypeof a
: a의 데이터타입을 문자열로 반환typeof null -> object
태생적으로 갖고 있는 버그때문에 object 타입으로 출력됨typeof undefined -> undefined
undefined == null
: True (값만 비교)undefined === null
: false (값, 데이터타입 비교)(!null)
-> true로 출력됨(!!null)
-> 이미 !null이 true로 반환되어서 !true가 되어 false로 출력됨. undefined도 동일함parameter
(매개변수): 함수에서 필요한 값 선언 및 저장하는 곳argument
(인수): 함수 호출 시 전달하는 값// 함수 선언
function sum(a, b) {
console.log(a + b);
}
// 함수 호출
sum(2, 10);
sum(10, 30);
if(age >= 18) {
console.log("adult");
} else {
console.log("kids");
}
// 위 조건문과 동일한 결과 출력
let result = (age>=18) ? "adult" : "kids";
console.log("result = " + result);
prompt
: 브라우저 환경에서 사용자에게서 정보 입력받기 위한 팝업창. 값은 문자로 저장됨alert
: 브라우저 환경에서 정보 전달만을 위한 팝업창 띄움const userId = prompt("아이디를 입력해주세요.");
const userPw = prompt("비밀번호를 입력해주세요");
console.log(userId);
console.log(userPw);
console.log(a); // undefined
var a;
a = "나는 a";
console.log(a);
console.log(b); // cannot access before inittialization 에러발생
let b;
console.log(b); // undefined
b = "나는 b";
console.log(b);
func1();
function func1 () {
console.log("func1 is a function.");
}
func1();
func2(); // 함수 선언 전 호출하면 not a function 에러발생
var func2 = function() {
console.log("func2 is a function.");
}
func2();
// Math.abs() 절댓값 반환 메소드
const num1 = Math.abs(-3);
console.log(num1);
// Math.ceil() 무조건 올림하는 메소드
const num2 = Math.ceil(0.43);
console.log(num2);
// Math.floor() 무조건 내림하는 메소드
const num3 = Math.floor(10.9);
console.log(num3);
// Math.random() 0에서 1 사이 랜덤한 숫자 뽑아내는 함수
const num4 = Math.random();
console.log(num4);
드디어 네이버 모바일 페이지까지 끝내서 카피캣 과정을 모두 완료했다. talk 리스트 부분을 만들 때 모든 리스트 객체에 해당되는 속성들을 잘 모아서 클래스화 한 것 같아서 뿌듯했다.
그리고 오늘부터 자바스크립트 강의를 들었는데 알고 있는 내용이 많아서 빠르게 들었다. 몇 번이나 다른 여러 강의를 통해 들은 내용이기도 했지만 제대로 알고 있지 못했던 내용도 있어서 정리를 좀 해보았다. 빨리 html로 만든 페이지에 자바스크립트를 적용하고 싶다.