网页技术交流
 
发新帖
楼主: 零五零八
查看: 943|回复: 0

[使用教程] 纯CSS3实现的井字棋游戏

[复制链接]
零五零八 发表于 2020-12-3 19:16:19 | 显示全部楼层
效果:

1.gif

HTML

  1. <div class="tic-tac-toe">
  2.   <input class="player-1 left first-column top first-row first-diagonal turn-1" id="block1-1-1" type="radio"/>
  3.   <label class="turn-1" for="block1-1-1"></label>
  4.   <input class="player-1 middle second-column top first-row turn-1" id="block1-1-2" type="radio"/>
  5.   <label class="turn-1" for="block1-1-2"></label>
  6.   <input class="player-1 right third-column top first-row second-diagonal turn-1" id="block1-1-3" type="radio"/>
  7.   <label class="turn-1" for="block1-1-3"></label>
  8.   <input class="player-1 left first-column center second-row turn-1" id="block1-2-1" type="radio"/>
  9.   <label class="turn-1" for="block1-2-1"></label>
  10.   <input class="player-1 middle second-column center second-row first-diagonal second-diagonal turn-1" id="block1-2-2" type="radio"/>
  11.   <label class="turn-1" for="block1-2-2"></label>
  12.   <input class="player-1 right third-column center second-row turn-1" id="block1-2-3" type="radio"/>
  13.   <label class="turn-1" for="block1-2-3"></label>
  14.   <input class="player-1 left first-column bottom third-row second-diagonal turn-1" id="block1-3-1" type="radio"/>
  15.   <label class="turn-1" for="block1-3-1"></label>
  16.   <input class="player-1 middle second-column bottom third-row turn-1" id="block1-3-2" type="radio"/>
  17.   <label class="turn-1" for="block1-3-2"></label>
  18.   <input class="player-1 right third-column bottom third-row first-diagonal turn-1" id="block1-3-3" type="radio"/>
  19.   <label class="turn-1" for="block1-3-3"></label>
  20.   <input class="player-2 left first-column top first-row first-diagonal turn-2" id="block2-1-1" type="radio"/>
  21.   <label class="turn-2" for="block2-1-1"></label>
  22.   <input class="player-2 middle second-column top first-row turn-2" id="block2-1-2" type="radio"/>
  23.   <label class="turn-2" for="block2-1-2"></label>
  24.   <input class="player-2 right third-column top first-row second-diagonal turn-2" id="block2-1-3" type="radio"/>
  25.   <label class="turn-2" for="block2-1-3"></label>
  26.   <input class="player-2 left first-column center second-row turn-2" id="block2-2-1" type="radio"/>
  27.   <label class="turn-2" for="block2-2-1"></label>
  28.   <input class="player-2 middle second-column center second-row first-diagonal second-diagonal turn-2" id="block2-2-2" type="radio"/>
  29.   <label class="turn-2" for="block2-2-2"></label>
  30.   <input class="player-2 right third-column center second-row turn-2" id="block2-2-3" type="radio"/>
  31.   <label class="turn-2" for="block2-2-3"></label>
  32.   <input class="player-2 left first-column bottom third-row second-diagonal turn-2" id="block2-3-1" type="radio"/>
  33.   <label class="turn-2" for="block2-3-1"></label>
  34.   <input class="player-2 middle second-column bottom third-row turn-2" id="block2-3-2" type="radio"/>
  35.   <label class="turn-2" for="block2-3-2"></label>
  36.   <input class="player-2 right third-column bottom third-row first-diagonal turn-2" id="block2-3-3" type="radio"/>
  37.   <label class="turn-2" for="block2-3-3"></label>
  38.   <input class="player-1 left first-column top first-row first-diagonal turn-3" id="block3-1-1" type="radio"/>
  39.   <label class="turn-3" for="block3-1-1"></label>
  40.   <input class="player-1 middle second-column top first-row turn-3" id="block3-1-2" type="radio"/>
  41.   <label class="turn-3" for="block3-1-2"></label>
  42.   <input class="player-1 right third-column top first-row second-diagonal turn-3" id="block3-1-3" type="radio"/>
  43.   <label class="turn-3" for="block3-1-3"></label>
  44.   <input class="player-1 left first-column center second-row turn-3" id="block3-2-1" type="radio"/>
  45.   <label class="turn-3" for="block3-2-1"></label>
  46.   <input class="player-1 middle second-column center second-row first-diagonal second-diagonal turn-3" id="block3-2-2" type="radio"/>
  47.   <label class="turn-3" for="block3-2-2"></label>
  48.   <input class="player-1 right third-column center second-row turn-3" id="block3-2-3" type="radio"/>
  49.   <label class="turn-3" for="block3-2-3"></label>
  50.   <input class="player-1 left first-column bottom third-row second-diagonal turn-3" id="block3-3-1" type="radio"/>
  51.   <label class="turn-3" for="block3-3-1"></label>
  52.   <input class="player-1 middle second-column bottom third-row turn-3" id="block3-3-2" type="radio"/>
  53.   <label class="turn-3" for="block3-3-2"></label>
  54.   <input class="player-1 right third-column bottom third-row first-diagonal turn-3" id="block3-3-3" type="radio"/>
  55.   <label class="turn-3" for="block3-3-3"></label>
  56.   <input class="player-2 left first-column top first-row first-diagonal turn-4" id="block4-1-1" type="radio"/>
  57.   <label class="turn-4" for="block4-1-1"></label>
  58.   <input class="player-2 middle second-column top first-row turn-4" id="block4-1-2" type="radio"/>
  59.   <label class="turn-4" for="block4-1-2"></label>
  60.   <input class="player-2 right third-column top first-row second-diagonal turn-4" id="block4-1-3" type="radio"/>
  61.   <label class="turn-4" for="block4-1-3"></label>
  62.   <input class="player-2 left first-column center second-row turn-4" id="block4-2-1" type="radio"/>
  63.   <label class="turn-4" for="block4-2-1"></label>
  64.   <input class="player-2 middle second-column center second-row first-diagonal second-diagonal turn-4" id="block4-2-2" type="radio"/>
  65.   <label class="turn-4" for="block4-2-2"></label>
  66.   <input class="player-2 right third-column center second-row turn-4" id="block4-2-3" type="radio"/>
  67.   <label class="turn-4" for="block4-2-3"></label>
  68.   <input class="player-2 left first-column bottom third-row second-diagonal turn-4" id="block4-3-1" type="radio"/>
  69.   <label class="turn-4" for="block4-3-1"></label>
  70.   <input class="player-2 middle second-column bottom third-row turn-4" id="block4-3-2" type="radio"/>
  71.   <label class="turn-4" for="block4-3-2"></label>
  72.   <input class="player-2 right third-column bottom third-row first-diagonal turn-4" id="block4-3-3" type="radio"/>
  73.   <label class="turn-4" for="block4-3-3"></label>
  74.   <input class="player-1 left first-column top first-row first-diagonal turn-5" id="block5-1-1" type="radio"/>
  75.   <label class="turn-5" for="block5-1-1"></label>
  76.   <input class="player-1 middle second-column top first-row turn-5" id="block5-1-2" type="radio"/>
  77.   <label class="turn-5" for="block5-1-2"></label>
  78.   <input class="player-1 right third-column top first-row second-diagonal turn-5" id="block5-1-3" type="radio"/>
  79.   <label class="turn-5" for="block5-1-3"></label>
  80.   <input class="player-1 left first-column center second-row turn-5" id="block5-2-1" type="radio"/>
  81.   <label class="turn-5" for="block5-2-1"></label>
  82.   <input class="player-1 middle second-column center second-row first-diagonal second-diagonal turn-5" id="block5-2-2" type="radio"/>
  83.   <label class="turn-5" for="block5-2-2"></label>
  84.   <input class="player-1 right third-column center second-row turn-5" id="block5-2-3" type="radio"/>
  85.   <label class="turn-5" for="block5-2-3"></label>
  86.   <input class="player-1 left first-column bottom third-row second-diagonal turn-5" id="block5-3-1" type="radio"/>
  87.   <label class="turn-5" for="block5-3-1"></label>
  88.   <input class="player-1 middle second-column bottom third-row turn-5" id="block5-3-2" type="radio"/>
  89.   <label class="turn-5" for="block5-3-2"></label>
  90.   <input class="player-1 right third-column bottom third-row first-diagonal turn-5" id="block5-3-3" type="radio"/>
  91.   <label class="turn-5" for="block5-3-3"></label>
  92.   <input class="player-2 left first-column top first-row first-diagonal turn-6" id="block6-1-1" type="radio"/>
  93.   <label class="turn-6" for="block6-1-1"></label>
  94.   <input class="player-2 middle second-column top first-row turn-6" id="block6-1-2" type="radio"/>
  95.   <label class="turn-6" for="block6-1-2"></label>
  96.   <input class="player-2 right third-column top first-row second-diagonal turn-6" id="block6-1-3" type="radio"/>
  97.   <label class="turn-6" for="block6-1-3"></label>
  98.   <input class="player-2 left first-column center second-row turn-6" id="block6-2-1" type="radio"/>
  99.   <label class="turn-6" for="block6-2-1"></label>
  100.   <input class="player-2 middle second-column center second-row first-diagonal second-diagonal turn-6" id="block6-2-2" type="radio"/>
  101.   <label class="turn-6" for="block6-2-2"></label>
  102.   <input class="player-2 right third-column center second-row turn-6" id="block6-2-3" type="radio"/>
  103.   <label class="turn-6" for="block6-2-3"></label>
  104.   <input class="player-2 left first-column bottom third-row second-diagonal turn-6" id="block6-3-1" type="radio"/>
  105.   <label class="turn-6" for="block6-3-1"></label>
  106.   <input class="player-2 middle second-column bottom third-row turn-6" id="block6-3-2" type="radio"/>
  107.   <label class="turn-6" for="block6-3-2"></label>
  108.   <input class="player-2 right third-column bottom third-row first-diagonal turn-6" id="block6-3-3" type="radio"/>
  109.   <label class="turn-6" for="block6-3-3"></label>
  110.   <input class="player-1 left first-column top first-row first-diagonal turn-7" id="block7-1-1" type="radio"/>
  111.   <label class="turn-7" for="block7-1-1"></label>
  112.   <input class="player-1 middle second-column top first-row turn-7" id="block7-1-2" type="radio"/>
  113.   <label class="turn-7" for="block7-1-2"></label>
  114.   <input class="player-1 right third-column top first-row second-diagonal turn-7" id="block7-1-3" type="radio"/>
  115.   <label class="turn-7" for="block7-1-3"></label>
  116.   <input class="player-1 left first-column center second-row turn-7" id="block7-2-1" type="radio"/>
  117.   <label class="turn-7" for="block7-2-1"></label>
  118.   <input class="player-1 middle second-column center second-row first-diagonal second-diagonal turn-7" id="block7-2-2" type="radio"/>
  119.   <label class="turn-7" for="block7-2-2"></label>
  120.   <input class="player-1 right third-column center second-row turn-7" id="block7-2-3" type="radio"/>
  121.   <label class="turn-7" for="block7-2-3"></label>
  122.   <input class="player-1 left first-column bottom third-row second-diagonal turn-7" id="block7-3-1" type="radio"/>
  123.   <label class="turn-7" for="block7-3-1"></label>
  124.   <input class="player-1 middle second-column bottom third-row turn-7" id="block7-3-2" type="radio"/>
  125.   <label class="turn-7" for="block7-3-2"></label>
  126.   <input class="player-1 right third-column bottom third-row first-diagonal turn-7" id="block7-3-3" type="radio"/>
  127.   <label class="turn-7" for="block7-3-3"></label>
  128.   <input class="player-2 left first-column top first-row first-diagonal turn-8" id="block8-1-1" type="radio"/>
  129.   <label class="turn-8" for="block8-1-1"></label>
  130.   <input class="player-2 middle second-column top first-row turn-8" id="block8-1-2" type="radio"/>
  131.   <label class="turn-8" for="block8-1-2"></label>
  132.   <input class="player-2 right third-column top first-row second-diagonal turn-8" id="block8-1-3" type="radio"/>
  133.   <label class="turn-8" for="block8-1-3"></label>
  134.   <input class="player-2 left first-column center second-row turn-8" id="block8-2-1" type="radio"/>
  135.   <label class="turn-8" for="block8-2-1"></label>
  136.   <input class="player-2 middle second-column center second-row first-diagonal second-diagonal turn-8" id="block8-2-2" type="radio"/>
  137.   <label class="turn-8" for="block8-2-2"></label>
  138.   <input class="player-2 right third-column center second-row turn-8" id="block8-2-3" type="radio"/>
  139.   <label class="turn-8" for="block8-2-3"></label>
  140.   <input class="player-2 left first-column bottom third-row second-diagonal turn-8" id="block8-3-1" type="radio"/>
  141.   <label class="turn-8" for="block8-3-1"></label>
  142.   <input class="player-2 middle second-column bottom third-row turn-8" id="block8-3-2" type="radio"/>
  143.   <label class="turn-8" for="block8-3-2"></label>
  144.   <input class="player-2 right third-column bottom third-row first-diagonal turn-8" id="block8-3-3" type="radio"/>
  145.   <label class="turn-8" for="block8-3-3"></label>
  146.   <input class="player-1 left first-column top first-row first-diagonal turn-9" id="block9-1-1" type="radio"/>
  147.   <label class="turn-9" for="block9-1-1"></label>
  148.   <input class="player-1 middle second-column top first-row turn-9" id="block9-1-2" type="radio"/>
  149.   <label class="turn-9" for="block9-1-2"></label>
  150.   <input class="player-1 right third-column top first-row second-diagonal turn-9" id="block9-1-3" type="radio"/>
  151.   <label class="turn-9" for="block9-1-3"></label>
  152.   <input class="player-1 left first-column center second-row turn-9" id="block9-2-1" type="radio"/>
  153.   <label class="turn-9" for="block9-2-1"></label>
  154.   <input class="player-1 middle second-column center second-row first-diagonal second-diagonal turn-9" id="block9-2-2" type="radio"/>
  155.   <label class="turn-9" for="block9-2-2"></label>
  156.   <input class="player-1 right third-column center second-row turn-9" id="block9-2-3" type="radio"/>
  157.   <label class="turn-9" for="block9-2-3"></label>
  158.   <input class="player-1 left first-column bottom third-row second-diagonal turn-9" id="block9-3-1" type="radio"/>
  159.   <label class="turn-9" for="block9-3-1"></label>
  160.   <input class="player-1 middle second-column bottom third-row turn-9" id="block9-3-2" type="radio"/>
  161.   <label class="turn-9" for="block9-3-2"></label>
  162.   <input class="player-1 right third-column bottom third-row first-diagonal turn-9" id="block9-3-3" type="radio"/>
  163.   <label class="turn-9" for="block9-3-3"></label>
  164.   <div class="end">
  165.     <h3></h3><a href="">Restart</a>
  166.   </div>
  167. </div>
  168. <h5>Note: use the Full Page view for the best experience.</h5>
复制代码



CSS3

  1. @charset "UTF-8";
  2. /* Variables
  3. -------------------------------------------------------------- */
  4. /* Body and Notice styling
  5. -------------------------------------------------------------- */
  6. body {
  7.   color: #b6b5ca;
  8.   font-family: 'Arial', sans-serif;
  9.   margin: 0;
  10.   text-align: center;
  11. }

  12. h5 {
  13.   font-weight: 400;
  14.   padding: 0 20px;
  15. }

  16. /* Tic-tac-toe game
  17. -------------------------------------------------------------- */
  18. .tic-tac-toe {
  19.   font-family: 'Open Sans', sans-serif;
  20.   height: 300px;
  21.   overflow: hidden;
  22.   margin: 50px auto 30px auto;
  23.   position: relative;
  24.   width: 300px;
  25. }
  26. @media (min-width: 450px) {
  27.   .tic-tac-toe {
  28.     height: 450px;
  29.     width: 450px;
  30.   }
  31. }
  32. .tic-tac-toe input[type="radio"] {
  33.   display: none;
  34. }
  35. .tic-tac-toe input[type="radio"]:checked + label {
  36.   cursor: default;
  37.   z-index: 10 !important;
  38. }
  39. .tic-tac-toe input[type="radio"].player-1 + label:after {
  40.   content: "";
  41. }
  42. .tic-tac-toe input[type="radio"].player-2 + label:after {
  43.   content: "";
  44. }
  45. .tic-tac-toe input[type="radio"].player-1:checked + label:after, .tic-tac-toe input[type="radio"].player-2:checked + label:after {
  46.   opacity: 1;
  47. }
  48. .tic-tac-toe input[type="radio"].player-1:checked + label {
  49.   background-color: #dc685a;
  50. }
  51. .tic-tac-toe input[type="radio"].player-2:checked + label {
  52.   background-color: #ecaf4f;
  53. }
  54. .tic-tac-toe input[type="radio"].turn-1 + label {
  55.   z-index: 1;
  56. }
  57. .tic-tac-toe input[type="radio"].turn-2 + label {
  58.   z-index: 2;
  59. }
  60. .tic-tac-toe input[type="radio"].turn-3 + label {
  61.   z-index: 3;
  62. }
  63. .tic-tac-toe input[type="radio"].turn-4 + label {
  64.   z-index: 4;
  65. }
  66. .tic-tac-toe input[type="radio"].turn-5 + label {
  67.   z-index: 5;
  68. }
  69. .tic-tac-toe input[type="radio"].turn-6 + label {
  70.   z-index: 6;
  71. }
  72. .tic-tac-toe input[type="radio"].turn-7 + label {
  73.   z-index: 7;
  74. }
  75. .tic-tac-toe input[type="radio"].turn-8 + label {
  76.   z-index: 8;
  77. }
  78. .tic-tac-toe input[type="radio"].turn-9 + label {
  79.   z-index: 9;
  80. }
  81. .tic-tac-toe input[type="radio"].turn-1 + label {
  82.   display: block;
  83. }
  84. .tic-tac-toe input[type="radio"].turn-1:checked ~ .turn-2 + label {
  85.   display: block;
  86. }
  87. .tic-tac-toe input[type="radio"].turn-2:checked ~ .turn-3 + label {
  88.   display: block;
  89. }
  90. .tic-tac-toe input[type="radio"].turn-3:checked ~ .turn-4 + label {
  91.   display: block;
  92. }
  93. .tic-tac-toe input[type="radio"].turn-4:checked ~ .turn-5 + label {
  94.   display: block;
  95. }
  96. .tic-tac-toe input[type="radio"].turn-5:checked ~ .turn-6 + label {
  97.   display: block;
  98. }
  99. .tic-tac-toe input[type="radio"].turn-6:checked ~ .turn-7 + label {
  100.   display: block;
  101. }
  102. .tic-tac-toe input[type="radio"].turn-7:checked ~ .turn-8 + label {
  103.   display: block;
  104. }
  105. .tic-tac-toe input[type="radio"].turn-8:checked ~ .turn-9 + label {
  106.   display: block;
  107. }
  108. .tic-tac-toe input[type="radio"].left + label {
  109.   left: 0;
  110. }
  111. .tic-tac-toe input[type="radio"].top + label {
  112.   top: 0;
  113. }
  114. .tic-tac-toe input[type="radio"].middle + label {
  115.   left: 100px;
  116. }
  117. .tic-tac-toe input[type="radio"].right + label {
  118.   left: 200px;
  119. }
  120. .tic-tac-toe input[type="radio"].center + label {
  121.   top: 100px;
  122. }
  123. .tic-tac-toe input[type="radio"].bottom + label {
  124.   top: 200px;
  125. }
  126. @media (min-width: 450px) {
  127.   .tic-tac-toe input[type="radio"].middle + label {
  128.     left: 150px;
  129.   }
  130.   .tic-tac-toe input[type="radio"].right + label {
  131.     left: 300px;
  132.   }
  133.   .tic-tac-toe input[type="radio"].center + label {
  134.     top: 150px;
  135.   }
  136.   .tic-tac-toe input[type="radio"].bottom + label {
  137.     top: 300px;
  138.   }
  139. }
  140. .tic-tac-toe input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~
  141. input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~
  142. input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~ .end {
  143.   display: block;
  144. }
  145. .tic-tac-toe input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~
  146. input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~
  147. input[type="radio"]:checked ~ input[type="radio"]:checked ~ input[type="radio"]:checked ~ .end > h3:before {
  148.   content: "It is a tie!";
  149. }
  150. .tic-tac-toe .player-1.first-column:checked ~ .player-1.first-column:checked ~ .player-1.first-column:checked ~ .end,
  151. .tic-tac-toe .player-1.second-column:checked ~ .player-1.second-column:checked ~ .player-1.second-column:checked ~ .end,
  152. .tic-tac-toe .player-1.third-column:checked ~ .player-1.third-column:checked ~ .player-1.third-column:checked ~ .end,
  153. .tic-tac-toe .player-1.first-row:checked ~ .player-1.first-row:checked ~ .player-1.first-row:checked ~ .end,
  154. .tic-tac-toe .player-1.second-row:checked ~ .player-1.second-row:checked ~ .player-1.second-row:checked ~ .end,
  155. .tic-tac-toe .player-1.third-row:checked ~ .player-1.third-row:checked ~ .player-1.third-row:checked ~ .end,
  156. .tic-tac-toe .player-1.first-diagonal:checked ~ .player-1.first-diagonal:checked ~ .player-1.first-diagonal:checked ~ .end,
  157. .tic-tac-toe .player-1.second-diagonal:checked ~ .player-1.second-diagonal:checked ~ .player-1.second-diagonal:checked ~ .end {
  158.   display: block;
  159. }
  160. .tic-tac-toe .player-1.first-column:checked ~ .player-1.first-column:checked ~ .player-1.first-column:checked ~ .end h3:before,
  161. .tic-tac-toe .player-1.second-column:checked ~ .player-1.second-column:checked ~ .player-1.second-column:checked ~ .end h3:before,
  162. .tic-tac-toe .player-1.third-column:checked ~ .player-1.third-column:checked ~ .player-1.third-column:checked ~ .end h3:before,
  163. .tic-tac-toe .player-1.first-row:checked ~ .player-1.first-row:checked ~ .player-1.first-row:checked ~ .end h3:before,
  164. .tic-tac-toe .player-1.second-row:checked ~ .player-1.second-row:checked ~ .player-1.second-row:checked ~ .end h3:before,
  165. .tic-tac-toe .player-1.third-row:checked ~ .player-1.third-row:checked ~ .player-1.third-row:checked ~ .end h3:before,
  166. .tic-tac-toe .player-1.first-diagonal:checked ~ .player-1.first-diagonal:checked ~ .player-1.first-diagonal:checked ~ .end h3:before,
  167. .tic-tac-toe .player-1.second-diagonal:checked ~ .player-1.second-diagonal:checked ~ .player-1.second-diagonal:checked ~ .end h3:before {
  168.   content: "Player 1 wins!" !important;
  169. }
  170. .tic-tac-toe .player-2.first-column:checked ~ .player-2.first-column:checked ~ .player-2.first-column:checked ~ .end,
  171. .tic-tac-toe .player-2.second-column:checked ~ .player-2.second-column:checked ~ .player-2.second-column:checked ~ .end,
  172. .tic-tac-toe .player-2.third-column:checked ~ .player-2.third-column:checked ~ .player-2.third-column:checked ~ .end,
  173. .tic-tac-toe .player-2.first-row:checked ~ .player-2.first-row:checked ~ .player-2.first-row:checked ~ .end,
  174. .tic-tac-toe .player-2.second-row:checked ~ .player-2.second-row:checked ~ .player-2.second-row:checked ~ .end,
  175. .tic-tac-toe .player-2.third-row:checked ~ .player-2.third-row:checked ~ .player-2.third-row:checked ~ .end,
  176. .tic-tac-toe .player-2.first-diagonal:checked ~ .player-2.first-diagonal:checked ~ .player-2.first-diagonal:checked ~ .end,
  177. .tic-tac-toe .player-2.second-diagonal:checked ~ .player-2.second-diagonal:checked ~ .player-2.second-diagonal:checked ~ .end {
  178.   display: block;
  179. }
  180. .tic-tac-toe .player-2.first-column:checked ~ .player-2.first-column:checked ~ .player-2.first-column:checked ~ .end h3:before,
  181. .tic-tac-toe .player-2.second-column:checked ~ .player-2.second-column:checked ~ .player-2.second-column:checked ~ .end h3:before,
  182. .tic-tac-toe .player-2.third-column:checked ~ .player-2.third-column:checked ~ .player-2.third-column:checked ~ .end h3:before,
  183. .tic-tac-toe .player-2.first-row:checked ~ .player-2.first-row:checked ~ .player-2.first-row:checked ~ .end h3:before,
  184. .tic-tac-toe .player-2.second-row:checked ~ .player-2.second-row:checked ~ .player-2.second-row:checked ~ .end h3:before,
  185. .tic-tac-toe .player-2.third-row:checked ~ .player-2.third-row:checked ~ .player-2.third-row:checked ~ .end h3:before,
  186. .tic-tac-toe .player-2.first-diagonal:checked ~ .player-2.first-diagonal:checked ~ .player-2.first-diagonal:checked ~ .end h3:before,
  187. .tic-tac-toe .player-2.second-diagonal:checked ~ .player-2.second-diagonal:checked ~ .player-2.second-diagonal:checked ~ .end h3:before {
  188.   content: "Player 2 wins!" !important;
  189. }
  190. .tic-tac-toe label {
  191.   background-color: #78bec5;
  192.   border-radius: 14px;
  193.   cursor: pointer;
  194.   color: #fff;
  195.   display: none;
  196.   height: 90px;
  197.   margin: 5px;
  198.   position: absolute;
  199.   width: 90px;
  200.   -moz-transition: background-color 0.3s;
  201.   -o-transition: background-color 0.3s;
  202.   -webkit-transition: background-color 0.3s;
  203.   transition: background-color 0.3s;
  204. }
  205. @media (min-width: 450px) {
  206.   .tic-tac-toe label {
  207.     height: 140px;
  208.     width: 140px;
  209.   }
  210. }
  211. .tic-tac-toe label:hover {
  212.   background-color: #3d4250;
  213. }
  214. .tic-tac-toe label:hover:after {
  215.   opacity: .4;
  216. }
  217. .tic-tac-toe label:after {
  218.   left: 0;
  219.   font-family: "FontAwesome";
  220.   font-size: 45px;
  221.   margin-top: -22.5px;
  222.   opacity: 0;
  223.   position: absolute;
  224.   text-align: center;
  225.   text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  226.   top: 50%;
  227.   width: 100%;
  228. }
  229. @media (min-width: 450px) {
  230.   .tic-tac-toe label:after {
  231.     font-size: 70px;
  232.     margin-top: -35px;
  233.   }
  234. }
  235. .tic-tac-toe .end {
  236.   background: rgba(255, 255, 255, 0.8);
  237.   bottom: 5px;
  238.   color: #3d4250;
  239.   display: none;
  240.   left: 5px;
  241.   padding-top: 55px;
  242.   position: absolute;
  243.   right: 5px;
  244.   top: 5px;
  245.   text-align: center;
  246.   z-index: 11;
  247. }
  248. @media (min-width: 450px) {
  249.   .tic-tac-toe .end {
  250.     padding-top: 110px;
  251.   }
  252. }
  253. .tic-tac-toe .end h3 {
  254.   font-size: 30px;
  255.   font-weight: 300;
  256. }
  257. @media (min-width: 450px) {
  258.   .tic-tac-toe .end h3 {
  259.     font-size: 40px;
  260.   }
  261. }
  262. .tic-tac-toe .end a {
  263.   background-color: #3d4250;
  264.   border-radius: 4px;
  265.   color: #fff;
  266.   padding: 14px 45px;
  267.   text-decoration: none;
  268.   -moz-transition: background-color 0.2s;
  269.   -o-transition: background-color 0.2s;
  270.   -webkit-transition: background-color 0.2s;
  271.   transition: background-color 0.2s;
  272. }
  273. .tic-tac-toe .end a:hover {
  274.   background-color: #262934;
  275.   cursor: pointer;
复制代码


快速回复 返回顶部 返回列表