본문 바로가기
개발 공부 Today I Learned

[국비 52일차 TIL] 미디어쿼리

by 개발자신입 2024. 2. 1.
반응형

media.jsp

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 미디어쿼리 반응형 -->

<title>미디어쿼리 연습</title>

 

<style type="text/css">

body{

background-color: gray;

}

@media screen and (min-width:1024px){ /* 데스크탑 */

body{

background-color: olive;

}

}

@media screen and (max-width:1023px){ /* 태블릿 */

body {

background-color: maroon;

}

}

@media screen and (max-width:540px){ /* 스마트폰 */

body {

background-color: navy;

}

}

 

</style>

 

<script type="text/javascript">

/* console.log(window.innerWidth);

console.log(window.innerHeight); */

window.onresize=function(event){

document.getElementById('size').textContent = window.innerWidth + " x " + window.innerHeight;

}

</script>

 

</head>

<body>

<h1 id="size">너비 : </h1>

</body>

</html>

반응형

댓글