Working with CSS in WP Rig is a straightforward process. You go into Assets, CSS and Source Folder, and then just write CSS the way you normally would. The build process detects any changes you make, and compiles out new minified CSS files that are then served up to the browser.
Let’s look at an example to see how this all fits together. If we take a look at the layout CSS for the current starter theme, you’ll see if we scroll up a bit there’s this div with id page and class site. This div has a grid layout applied to it. Display grid and in Firefox you can use the overlay grid to actually see that grid in the browser. Now, this grid currently has two columns, one that takes up three portions of the available space, and one that takes up one portion of the available space. This was defined here, grid template columns 3fr and 1fr, and all of this is defined inside global.css on line 81.
I want to change this mark up so that I can use grid template areas and position the different elements that way, because that makes it easier if I ever want to change the layout, maybe place the sidebar on the left-hand side instead of the right-hand side and so on.
Because I’m going to do development now, I’ll spin up my development process. That way, any changes I make in CSS files or any other files will automatically be detected and new files are generated by the build process.
Now I go to global.css and find the rule in question. It’s right here, has-sidebar.site, and here we have display grid and then grid template columns 3fr 1fr. I’m going to change this here first to say repeat and then four, 1fr. That gives me four equal width columns. Then I’ll set up grid template areas and here inside the areas, I’ll give the different areas names. So in the layout I first have a header that takes up all the available columns, so I’ll say header header header header. Then, I’ll set up the main area, so main main main and sidebar. And then finally the footer so footer footer footer footer and end it all with a semicolon.
Now I can use these grid areas to position the different elements. When I save global.css, the build process detects that something has changed in this file. The stall process runs again, and the browser is updated. You’ll see the build process detects a change in the style, runs the style process again, the new style sheet is built out. Any change you make in any of the CSS files, either the main style sheets or the partials, including custom properties and custom media, will automatically be detected by the build process, the build process will take those changes, run through the entire styles build and create new minified style sheets that are then served up to the browser automatically.