index.html
file파일을 생성해주세요"<meta name="viewport">
를 넣어주세요" 라고 나온다.그럼 대체 viewport가 무엇일까?
현재 화면에 보여지고 있는 영역을 의미한다.
기기 별로 Viewport가 다르기 때문에, 동일한 웹페이지라도 기기에 따른 배율 조정이 발생해 화면의 크기가 다르게 보이는 현상이 나타난다.
기존 PC
모바일 및 태블릿
그래서 필요한게 viewport
로
head 태그 사이에 코드로 입력한다.
html<meta name="viewport" content="width=device-width, initial-scale=1.0">
기본적으로 데스크탑 브라우저에서는 viewport 메타 태그
를 사용하지 않기 때문에 무시된다.
즉, 모바일 환경에서만 적용된다는 것이다.
device-width
와 같은 특정한 값을 사용할 수도 있다. device-width
는 100% 스케일에서 CSS 픽셀들로 계산된 화면의 폭을 의미합니다.<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- 추가해야될 중요포인트 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>