개인 개발 프로젝트/그림판 앱

[그림판 앱] 3. reset.css, style.css

종범2 2020. 4. 5. 22:16

프로젝트에서는 두 개의 css 파일을 사용한다. reset.css와 style.css이다. 우선 reset.css에 대해 설명하겠다. reset.css는 직접 작성한 파일은 아니다. reset.css는 css를 초기화하기 위해 사용하는 파일이다. 브라우저마다 기본 태그의 스타일이 다르기 때문에 먼저 초기화를 한 후에 스타일을 적용시켜야 한다. reset.css는 다양한 버전이 있어 각자의 상황에 맞게 사용하면 된다. 이 프로젝트에서는 여기의 reset.css를 사용하였다.

 

https://gist.github.com/DavidWells/18e73022e723037a50d6

 

reset.css

GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

reset.css 이후에는 style.css를 작성하여 스타일을 적용하였다. style.css는 다음과 같다.

 

style.css

body{
  min-width:700px;  
  background-color: #f6f9fc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.title{
  color: 1px solid rgba(0,0,0,0.8);
  font-weight: bold;
  font-size: 20px;
  text-align: center;
  margin: 20px
}
.text{
  color: 1px solid rgba(0,0,0,0.8);
  font-weight: bold;
  font-size: 15px;
  height: 24px;
  line-height: 24px;
  margin-right: 10px;
}
.content{
  text-align: center;
}
.canvas{
  cursor: crosshair;
  margin-top: 20px;
  background-color: white;
  border-radius: 15px;
  box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.controls{
  margin-top:20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.controls__width, .controls__height{
  color: 1px solid rgba(0,0,0,0.8);
  font-size: 15px;
  height: 18px;
  width: 50px;
  margin-right: 10px;
  padding-left: 5px;
}
.controls__btns{
  margin-top: 20px;
}
button{
  all: unset;
  cursor: pointer;
  background-color: white;
  padding: 5px 0px;
  width: 80px;
  text-align: center;
  border-radius: 5px;
  box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0,0,0,0.2);
  color: 1px solid rgba(0,0,0,0.8);
  text-transform: uppercase;
  font-weight: 600;
  font-size: 12px;
}
button:active{
  transform: scale(0.98);
}
.controls__size{
  display: flex;
}
.controls__colors{
  margin-top:20px;
  display: flex;
}
.controls__color {
  margin-left: 5px;
  width: 50px;
  cursor: pointer;
  border-radius: 25px;
  height: 50px;
  box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
  color: 1px solid rgba(0,0,0,0.8);
  text-transform: uppercase;
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  line-height: 50px;
}
.controls__color:active{
  transform: scale(0.98);
}
.controls__color__clicked{
  border-color: #4195fc;
  box-shadow: 0px 0px 15px #4195fc;
}
input[type=range]{
  -webkit-appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
  width: 300px;
  height: 5px;
  background: #ddd;
  border: none;
  border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: grey;
  margin-top: -4px;
}
input[type=range]:focus {
  outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
  background: #ccc;
}

 

전체적으로 Body안에 컴포넌트들을 위치시키고 가운데 정렬을 하였다. 컴포넌트 내부에서는 가운데 정렬로 가로로 위젯을 위치시켰다. 이를 위해 다음과 같이 css를 작성하였다. 자주 사용되는 형태의 css이므로 정리를 할겸 그림으로 작성하였다.

 

첫 번째 박스에 해당하는 위젯이 body 태그, 두 번째 박스에 해당하는 위젯이 controls라는 클래스 네임을 가진 div 태그, 세 번째 박스에 해당하는 위젯이 controls_size, controls_colors라는 클래스 네임을 가진 div 태그가 된다.

 

[전체 글]

[그림판 앱] 5. 마무리

[그림판 앱] 4. app.js

[그림판 앱] 3. reset.css, style.css

[그림판 앱] 2. index.html

[그림판 앱] 1. 프로젝트 소개