Created
October 13, 2020 14:14
-
-
Save tannineo/b9d695763e085d579e222691bd83d804 to your computer and use it in GitHub Desktop.
a flex chessboard test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title></title> | |
| </head> | |
| <body> | |
| <script> | |
| var numbersqu = prompt('how big do you want of the chessboard'); | |
| var sizesqu = prompt('the size of square'); | |
| var lengthsqu = numbersqu * sizesqu; | |
| function set() { | |
| document.write( | |
| '<div style="width:' + | |
| lengthsqu + | |
| 'px; height: ' + | |
| lengthsqu + | |
| 'px;border: 1px solid #000000;">' | |
| ); | |
| for (var i = 1; i <= numbersqu; i++) { | |
| for (var j = 1; j <= numbersqu; j++) { | |
| if (i % 2) { | |
| if (j % 2) { | |
| printOdd(); | |
| } else { | |
| printEven(); | |
| } | |
| } else { | |
| if (j % 2) { | |
| printEven(); | |
| } else { | |
| printOdd(); | |
| } | |
| } | |
| } | |
| } | |
| document.write('</div>'); | |
| } | |
| function printEven() { | |
| document.write('<div style="display: flex;"></div>'); | |
| document.write( | |
| '<div style="background: lightgray; border-color: black;width: ' + | |
| sizesqu + | |
| 'px; height:' + | |
| sizesqu + | |
| 'px; float:left"></div>' | |
| ); | |
| } | |
| function printOdd() { | |
| document.write('<div style="display: flex;"></div>'); | |
| document.write( | |
| '<div style="background: black; width: ' + | |
| sizesqu + | |
| 'px; height:' + | |
| sizesqu + | |
| 'px; float:left"></div>' | |
| ); | |
| } | |
| set(numbersqu); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment