웹 공부/javascript
코딩 스터디[모각코] 1일차 - 한 입 웹개발(JS)
윈터가든
2021. 7. 5. 16:04
✅ 오늘의 문제 풀이 인증
<HTML 코드>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>javascript1</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Gamja+Flower&display=swap" rel="stylesheet">
<link rel="stylesheet" href="1.css">
</head>
<body>
<div class="box">
<a>냐앙~</a>
</div>
<img src="img/고양이.jpg" alt="">
<input type="text">
<button>시키기</button>
</body>
</html>
<CSS 코드>
*{
font-family: 'Gamja Flower', cursive;
}
.box{
text-align: center;
line-height: 200px;
width: 500px;
height: 200px;
border-style: solid;
border-color: rgb(126, 91, 66);
border-width:4px;
border-radius: 5px;
margin-bottom: 30px;
margin-left: auto;
margin-right: auto;
font-size: 30px;
position: relative;
}
img{
display: block;
width: 300px;
margin-bottom: 30px;
margin-left: auto;
margin-right: auto;
position: relative;
}
input[type=text]{
display: block;
border: 3px solid peru;
border-radius: 5px;
height: 30px;
width: 300px;
font-size: 12pt;
text-align: center;
box-sizing: border-box;
margin-bottom: 20px;
margin-left: auto;
margin-right: auto;
position: relative;
}
button{
display: block;
margin-right: auto;
margin-left: auto;
background-color: navajowhite;
border: none;
border-radius: 30px;
width: 200px;
height: 50px;
font-size: 30px;
color: white;
}
<결과화면>
✅ 오늘의 한마디
👉 CSS에서 margin: 0 auto;는 정가운데에 위치하도록 합니다. 좌우 가운데 정렬만 시키고 싶으면 display: block; margin-left: auto; margin-right: auto;를 해줘야 합니다. 과제를 하면서 막혔던 부분도 있었지만 검색을 통해 직접 해결하고, 새로운 것도 많이 배워 시간 가는 줄 모르고 재밌게 할 수 있었습니다. 남은 과정도 성실히 참여하겠습니다 ๑•‿•๑