Programming Storytelling

html/css로 스도쿠 구현하기 본문

HTML & CSS & JS

html/css로 스도쿠 구현하기

HJdone 2019. 4. 15. 19:56

들어가기 전 알아야 할 html/css 배경지식

##태그##


1.<table>:테이블을 만드는 태그

2.<th>:테이블의 헤더를 만드는 태그(테이블의 데이터를 만들어준다.부연설명을 덧붙이자면 테이블의 제목을 의미한다.)

3.<tr>:테이블의 행을 만들어준다.(세로)

4.<td>:테이블의 열을 만들어준다.(가로)

스도쿠란,가로나 세로 그리고 3*3정사각형 부근안에 1~9가 각각 들어가면 되는것이다.(숫자 중복 허용 x)


##속성##

border

테이블의 테두리

bordercolor

테이블의 테두리 색상

width

테이블 가로 크기

height

테이블 세로 크기

align

정렬

bgcolor

배경색

colspan

가로 합병(열 합병)

rowspan

세로 합병(행 합병)

  • 셀 병합
  • 행 분할
  • 열 분할
  • 너비 맞춤
  • 삭제

@index.html


<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<link rel="stylesheet" href="index.css">

</head>

<body>

 

<div class="container">

<h1 id = "T"><center>Sudoku</center></h1>

 

<table id="grid">

 

<tr>

<td><input id = "cell-0" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-1" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-2" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-3" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-4" type = "number" min = "1" max = "9"></td>

<td><input id="cell-5" type="number" value = "4" disabled></td>

<td><input id = "cell-6" type = "number" value = "7" disabled></td>

<td><input id = "cell-7" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-8" type = "number" value = "8" disabled></td>

</tr>

 

<tr>

<td><input id = "cell-9" type = "number" value = "7" disabled></td>

<td><input id = "cell-10" type = "number" value = "1" disabled></td>

<td><input id = "cell-11" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-12" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-13" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-14" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-15" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-16" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-17" type = "number" min = "1" max = "9"></td>

</tr>

 

<tr>

<td><input id = "cell-18" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-19" type = "number" value = "5" disabled></td>

<td><input id = "cell-20" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-21" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-22" type = "number" value = "8" disabled></td>

<td><input id = "cell-23" type = "number" value = "7"></td>

<td><input id = "cell-24" type = "number" value = "6" disabled></td>

<td><input id = "cell-25" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-26" type = "number" min = "1" max = "9"></td>

</tr>

 

<tr>

<td><input id = "cell-27" type = "number" value = "3" disabled></td>

<td><input id = "cell-28" type = "number" value = "7" disabled></td>

<td><input id = "cell-29" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-30" type = "number" value = "6" disabled></td>

<td><input id = "cell-31" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-32" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-33" type = "number" value = "9" disabled></td>

<td><input id = "cell-34" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-35" type = "number" min = "1" max = "9"></td>

</tr>

 

<tr>

<td><input id = "cell-36" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-37" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-38" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-39" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-40" type = "number" value = "5" disabled></td>

<td><input id = "cell-41" type = "number" value = "3" disabled></td>

<td><input id = "cell-42" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-43" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-44" type = "number" min = "1" max = "9"></td>

</tr>

 

<tr>

<td><input id = "cell-45" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-46" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-47" type = "number" value = "9" disabled></td>

<td><input id = "cell-48" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-49" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-50" type = "number" value = "1" disabled></td>

<td><input id = "cell-51" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-52" type = "number" value = "5" disabled></td>

<td><input id = "cell-53" type = "number" value = "2" disabled></td>

</tr>

 

<tr>

<td><input id = "cell-54" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-55" type = "number" value = "6" disabled></td>

<td><input id = "cell-56" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-57" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-58" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-59" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-60" type = "number" value = "2" disabled></td>

<td><input id = "cell-61" type = "number" value = "8" disabled></td>

<td><input id = "cell-62" type = "number" min = "1" max = "9"></td>

</tr>

 

<tr>

<td><input id = "cell-63" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-64" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-65" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-66" type = "number" value = "4" disabled></td>

<td><input id = "cell-67" type = "number" value = "1" disabled></td>

<td><input id = "cell-68" type = "number" value = "9" disabled></td>

<td><input id = "cell-69" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-70" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-71" type = "number" value = "5" disabled></td>

</tr>

 

<tr>

<td><input id = "cell-72" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-73" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-74" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-75" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-76" type = "number" value = "8" disabled></td>

<td><input id = "cell-77" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-78" type = "number" min = "1" max = "9"></td>

<td><input id = "cell-79" type = "number" value = "7" disabled></td>

<td><input id = "cell-80" type = "number" value = "9" disabled></td>

</tr>

 

</table>

 

</div>

<p></p>

<center><button>Check your answers</button></center>

</body>

</html>



@index.css


#T {

color: #008B8B;

}

html, body {

background-color: #FAFAFA

}

table {

border: 2px solid #000000;

margin: auto;

}

td {

border: 1px solid #000000;

text-align: center;

vertical-align: middle;

}

input {

color: #000000;

padding: 0;

border: 0;

text-align: center;

width: 48px;

height: 48px;

font-size: 24px;

background-color: #FFFFFF;

outline: none;

}

input:disabled {

background-color: #EEEEEE;

}

#cell-0, #cell-1, #cell-2 { border-top: 2px solid #000000; }

#cell-2, #cell-11, #cell-20 { border-right: 2px solid #000000; }

#cell-18, #cell-19, #cell-20 { border-bottom: 2px solid #000000; }

#cell-0, #cell-9, #cell-18 { border-left: 2px solid #000000; }

#cell-3, #cell-4, #cell-5 { border-top: 2px solid #000000; }

#cell-5, #cell-14, #cell-23 { border-right: 2px solid #000000; }

#cell-21, #cell-22, #cell-23 { border-bottom: 2px solid #000000; }

#cell-3, #cell-12, #cell-21 { border-left: 2px solid #000000; }

#cell-6, #cell-7, #cell-8 { border-top: 2px solid #000000; }

#cell-8, #cell-17, #cell-26 { border-right: 2px solid #000000; }

#cell-24, #cell-25, #cell-26 { border-bottom: 2px solid #000000; }

#cell-6, #cell-15, #cell-24 { border-left: 2px solid #000000; }

#cell-27, #cell-28, #cell-29 { border-top: 2px solid #000000; }

#cell-29, #cell-38, #cell-47 { border-right: 2px solid #000000; }

#cell-45, #cell-46, #cell-47 { border-bottom: 2px solid #000000; }

#cell-27, #cell-36, #cell-45 { border-left: 2px solid #000000; }

#cell-30, #cell-31, #cell-32 { border-top: 2px solid #000000; }

#cell-32, #cell-41, #cell-50 { border-right: 2px solid #000000; }

#cell-48, #cell-49, #cell-50 { border-bottom: 2px solid #000000; }

#cell-30, #cell-39, #cell-48 { border-left: 2px solid #000000; }

#cell-33, #cell-34, #cell-35 { border-top: 2px solid #000000; }

#cell-35, #cell-44, #cell-53 { border-right: 2px solid #000000; }

#cell-51, #cell-52, #cell-53 { border-bottom: 2px solid #000000; }

#cell-33, #cell-42, #cell-51 { border-left: 2px solid #000000; }

#cell-54, #cell-55, #cell-56 { border-top: 2px solid #000000; }

#cell-56, #cell-65, #cell-74 { border-right: 2px solid #000000; }

#cell-72, #cell-73, #cell-74 { border-bottom: 2px solid #000000; }

#cell-54, #cell-63, #cell-72 { border-left: 2px solid #000000; }

#cell-57, #cell-58, #cell-59 { border-top: 2px solid #000000; }

#cell-59, #cell-68, #cell-77 { border-right: 2px solid #000000; }

#cell-75, #cell-76, #cell-77 { border-bottom: 2px solid #000000; }

#cell-57, #cell-66, #cell-75 { border-left: 2px solid #000000; }

#cell-60, #cell-61, #cell-62 { border-top: 2px solid #000000; }

#cell-62, #cell-71, #cell-80 { border-right: 2px solid #000000; }

#cell-78, #cell-79, #cell-80 { border-bottom: 2px solid #000000; }

#cell-60, #cell-69, #cell-78 { border-left: 2px solid #000000; }

 

#차후에는 멋진 스도쿠사이트를 만들어보고 싶다.