- Overview
- Transcript
5.4 Style the Chess Board
Our board doesn't look quite right yet, but a bit of CSS will make it look like a proper chess board.
1.Getting Started3 lessons, 11:39
1.1Introduction00:39
1.2Application Demo05:23
1.3Application Setup05:37
2.First Steps4 lessons, 19:19
2.1Organizing Your Code05:44
2.2Set Up a Router07:24
2.3Add User Accounts03:39
2.4Collections02:32
3.The User List Page3 lessons, 23:41
3.1List Users12:38
3.2Making Friends04:57
3.3Write a First Meteor Method06:06
4.The Game List Page4 lessons, 39:05
4.1Waiting for Data08:15
4.2New Game Form08:35
4.3New Game Method09:42
4.4List the Games12:33
5.The Game Page10 lessons, 1:28:25
5.1Get the Game Data04:53
5.2Display the Game: Prep Work11:40
5.3Display the Game12:00
5.4Style the Chess Board02:50
5.5Making Moves: The Event Handler16:54
5.6Making Moves: The Meteor Method10:00
5.7Listing the Moves06:48
5.8Chat Between Users11:56
5.9Reviewing the Game09:29
5.10Deploy the Application01:55
6.Conclusion1 lesson, 00:44
6.1Conclusion00:44
5.4 Style the Chess Board
In the previous lesson, we were finally able to display our chessboard to the user. However, it doesn't look quite what you would expect the chessboard to look like. So in this lesson, we're going to add a little bit of styling. So it doesn't really matter where we put the CSS file, so I'm just gonna make a new style.css file right in the root of the directory. Okay so this is going to be quick and easy. Let's add some styling to our table element. Let's give it a border. And one pixel solid CCC so just maybe a light shade of gray. And we want to make the piece of bit bigger so let's make the font size up to 25 pixels. And finally lets do margin auto just to kind of center it in the grid space that we've given it. Okay, already that is starting to look a little bit better. Let's work with the individual table data elements which are our individual cells. So let's give them a width of 40 pixels and let's give them a height of 40 pixels as well. And then why don't we set text-align to center. So that they'll be centered in the cell and finally let's set the cursor to pointer. Because these cells will be clickable, right?. Let's give them a cursor that lets them know that. Well that certainly looks much better. Although you may notice the one obvious thing we're missing. And that is the actual chessboard pattern or checkerboard pattern if you will. You can do this with some fancy CSS selectors. So for our table row let's use the nth child selector. And we will say 2n+1, which means every second row using the odd rows. So this is going to be the first row, the third row, etc. And inside of this we want to look for table data cells that are the nth-child(2n), so all the even cells in the odd rows. And those should all have a background of that grey color we're using CCC. Now this is only half of it right. Because if you look at this we have the odd numbered rows right so row one three. Five and seven, and we have even numbered cells. Cells two, four, six and eight, and those are colored gray. However, we also need to do the reverse of that, right? So we need to look at the even numbered rows, and all the odd numbered cells within those rows. So let's add a second selector here. And I'll just space this out a bit. And this is going to be the table row where the nth child is 2n. And then inside that the table data cell where nth child is 2n plus 1. All right, so let's see. There we go, that is exactly right, and as you can see we now have a properly set up a chessboard. We know that the board is oriented the right way because the bottom right should always be white and it is, and so we're good. So now we have a chessboard displaying to our users. The next step is to allow them to actually make some moves. So we'll look at that in the next lesson.