Today, we are going to make what we have done so far look ‘pretty’ 🙂 More specifically, the User Interface (UI). For this web application, I am going to pick some colors that look good together and using Cascading Style Sheets (CSS), add them to the HyperText Markup Language (HTML) controls as well as arrange them in a pleasing fashion.
Yet again, I ended up breaking this into multiple Git Commits:
One of the simpliest things to do use to use HTML tables. However, using <div>’s and <span>’s arranged with CSS positioning is more of what I see today. So, we will be using the later. So, let’s take stock of what we have in our application and what we want it to look like.
We need a .css file, so let’s add that. I am going to call it desktopsite.css and will leave it empty for now. This is the only .css file I think this site will use. However, I name it with a meaningful name so that in case I want to add others (perhaps a mobile version), I can and it is very easy to quickly know which file is for which version of the site.
We have two pages – a summary location list and a details page. I think we need a title to combine them. Let’s call it ‘The Awesome Location Manager’ (TALM). This will go on both pages, so we need to create a header. In most sites I have worked on and/or created in the past, a footer is a requirement. For this site, I am not going to add it though. If I had, it would be very, very similar to the title we just created. We add the title as a partial view that resides in the ‘Shared’ folder.
Title View Rendered
Now, let’s add some <div>’s to our two pages and title partial view. We will use these for positioning and other stylistic options. Something to remember is to think from a composition perspective. More specifically, you are ‘composing’ a picture (i.e. page). What do you want it to look like? Once you have an idea in your head, break out these visual sections of the page (i.e. HTML elements) into components that can be easily manipulated.
For the location summary, we need a sub-title, a list of locations and buttons to handle the functionality. Again, all existing elements from the previous posts, but now they are in the layout we plan to use. If you notice, I have already applied the styles. I had planned to show this in a more step by step fashion, but in playing with the colors and positioning, I went through several versions. Showing all that is a lot for one blog post 🙂
For the location details, we again need a sub-title, function buttons and two list areas – one for the read-only view and one for the create/update functionality.
I think we are ready for some some color. I got the color scheme from one of the samples in reference #4. In my experience, simple is best.
- background – white
- foreground/accent – #695DBD
Digging into desktopsite.css, I like to start out generic and get more specific as needed. So, I define the background and banner (i.e. shared Title partial view) and work my way down.
Couple of interesting things to point out:
- In the past, I have either used a . for a class or # to refer to a specific named HTML control. You can also refer to types of HTML controls and the styling will be applied to any matching control. This is how I set up the location summary list (i.e. <ul>).
- You can chain css styles together on one control. This is really useful in you want to share one css style among st many controls.
I then import the style sheet and voila, we have color!