Mobile-First Responsive Build #4 - Base Styles

Net Ninja · Beginner ·🌐 Frontend Engineering ·6y ago
Skills: HTML & CSS90%

Key Takeaways

Creates base styles for a website using CSS variables and resets

Full Transcript

I rather than gang so in this video I'd like to dive right into the CSS and to begin we focus on some core base styles to style up elements that aren't really going to change whether we view on a mobile or a desktop so things like buttons or input fields and colors now I want to start off by declaring a couple of variables now we can create variables in CSS to store values that we might commonly use through different rules so things like colors or font sizes now I'm going to declare a couple of variables for colors so I'm just gonna paste this in first of all and you can see the selector I've used is : root and what that does is select the roots elements inside the document so the HTML tag in this case and it means that whatever variables we define right here we can use in selectors which target any of the items inside the HTML document okay so inside the root selector I say Double Dash and then the name of whatever variable I want to use I've called it primary you can call it what you want and the value is this yellow color the second one is called secondary and I've used a blue color so now we can just refer to these variables in the future to use these colors and if we need to change the colors we change it once up here and not several times where we use it down below okay so there the variables the next thing I want to do is a quick reset because I want to reset some of the default browser styles we can see that without any of our own styles already the browser has styled the h1 the h2 to make them larger and bold also the anchor tags that we underlined and the Li tags have these little circle icons and also the UL has a margin as well as these things these also have margins as well top and bottom so I want to strip out some of those default browser styles so that we have more of a blank slate to work with so to do that first of all I'm going to target the Li tags and remove these little icons and to do that we say list - style - type this one and set that to none so if I save this now we're going to strip out those little circle icons awesome and the next thing I want to do is take out some of the margin and the and also the text-decoration of these things so I'm just gonna grab a few different things at once I'm going to say body and also P tags a tags you ELLs and allies and then inside I'm going to say margin is zero also the padding will be zero and also the text decoration is going to be not okay so if we save that then it should strip out a lot of the margin and padding of these things up here and also remove the underline for the anchor tags because of this thing right here okay so that's the basic reset next I want to move on to some base styles and we'll start with the body tag so the body right here is gonna have a background color and it's going to be this color right here so we can just use this variable so all I'm gonna do is say background is then going to be a variable and the way we use a variable is saying var and then in brackets whatever variable we want to use so double dash secondary like so it uses this value right here defined for a secondary so if I save this check this out now we get that background color awesome okay the next thing I want to do is say overflow in the X Direction is going to be hidden and the reason I'm doing that is because later on when we use this image over on the right up here I'm going to push it off the screen I don't want a user to be able to scroll and view that image okay so that will become more apparent while we're doing that later on for now let's move on to the next thing which is going to be for buttons so this right here in view my work is a button and we can see that because it has a button class if I can find it up here somewhere there we give this a class of button also down here at the forum we have a class of button as well so we're going to style up that class so let me say dots button and in here first of all I'm going to say the background is going to be not because by default down here we do have a background on this it's an import field we don't on this anchor tag but because we have an input field down here with the class of button and when I strip that background out as well so background on the is going to be two pixels it's going to be solid and the color is again going to be a very ball and this time - - and it's going to be primary so that's the yellow color we used so after that I'm going to say the color of the text inside the button is going to be a variable and it's also going to be primary so the color of the yellow again and then the padding of a button is going to be six pixels top and bottom and also 12 pixels left and right we also want a border radius which makes it more circular at the edges at the corners so we'll say border radius is going to be 20 pixels then after that I want to say text transform and that is going to be uppercase and then let's just see how this looks so far all right looking pretty good and looking pretty good up here as well I just want to do a couple more things I want to say the Box shadow just to give it a little drop shadow at the back is gonna be one pixels two pixels three pixels and then rgba and we use a right here to add an alpha channel at the end which means we can add a bit of a pass at it and the value inside here it's going to be zero zero zero which is black RGB and then the opacity is going to be not 0.6 all right so this is only going to be a subtle drop shadow but if I save it we can view that little drop shadow now right here okay all right so now we want to also display this as inline - block that's going to help us with styling that later on and adding some margin to it alright cool so that is the bottom class done I also want a hover effect so I'm gonna say button hover and in this case I want the color of the text to be a bit darker so no longer yellow - - - like a dark grey and the background this time is going to be a variable which is going to be the secondary or rather no the primary color again because that's the yellow color so save that and if we hover we can see we now get that style right here so this is the benefit of using variables by the way we can just use variables right here instead of outputting the same hex code over and over again then if we want to update the theme or the colors of our site in the future we just change that value once at the top and then it's going to automatically update everywhere else we don't have to change all these anymore so that's why we're using variables okay so we've done the buttons now I also want to style up the input fields down here because they're not really going to change that much as we go from a small screen to a large screen so let me say input and also text area which is this one right here this one so text area and input and inside here we're going to give this a background color so background and that is going to be RGB a again so we can add an alpha Channel 255 255 255 which is white then add some opacity naught point zero five so it's going to be a really faint white and we should see a lot of the blue from underneath the background poking through so it should be kind of like a blue similar to this background color but a bit lighter so if we save it we can see that right here and it almost looks the same okay so now I'm going to say padding is going to be ten pixels in the top and bottom direction and 16 pixels left and right border radius is going to be 20 pixels to make it softer at the corners as well looks like the button and the border itself is going to be 2 pixels solid and I'm going to use a hex code for this because but only going to use it probably once inside our CSS file and that is going to be 9 8 9 3 D 8 okay so if I save it and take a look that's looking a bit better all right so next I just want to do a color of the text if I type it at the minute it's probably going to be black yep it is I want to make it more of a kind of light gray when a user types into it so color is going to be F 2 F 2 F 2 alright so save that and you can see now it's looking a bit better so I think that's about it there all of our base core styles for this website so now we've started D things the buttons we've stripped away some of the default browser styles and also we've added these variables right here and by the way the reason I'm previewing this just in a small screen and I'm not doing this fullscreen like this is because remember we're using a mobile first approach so at the minute we're just concerned about making it look good on mobiles like this now in the next video I want to address the fonts and adding a custom font as well so we'll take a look at that next

Original Description

Hey gang, in this mbile-first responsive tutorial we'll flesh out just some of the base styes for our website - fonts, colours, reset, that kind of thing. 🐱‍👤🐱‍👤 JOIN THE CAUSE - https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg/join ---------------------------------------- 🐱‍💻 🐱‍💻 My Udemy Courses: + Modern JavaScript - https://www.thenetninja.co.uk/udemy/modern-javascript + Vue JS & Firebase - http://www.thenetninja.co.uk/udemy/vue-and-firebase + D3.js & Firebase - https://www.thenetninja.co.uk/udemy/d3-and-firebase 🐱‍💻 🐱‍💻 Course Links: Course files - https://github.com/iamshaunjp/responsive-css-grid-build 🐱‍💻 🐱‍💻 Other Related Courses: + HTML & CSS Crash Course - https://www.youtube.com/playlist?list=PL4cUxeGkcC9ivBf_eKCPIAYXWzLlPAm6G + CSS Grid for Beginners - https://www.youtube.com/playlist?list=PL4cUxeGkcC9itC4TxYMzFCfveyutyPOCY 🐱‍💻 🐱‍💻 The Net Ninja Community Boards: https://community.thenetninja.co.uk/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

📰
Inside the Wayfair Frontend SDE-2 Interview: A Complete Breakdown
Learn how to prepare for a Frontend SDE-2 interview at Wayfair, including online assessments, machine coding, and system design.
Medium · Programming
📰
I Spent Two Years Maintaining a React SPA. HTMX Rebuilt It in a Week
Learn how HTMX rebuilt a React SPA in a week, replacing 2 years of maintenance work, and discover the benefits of this alternative approach
Medium · Programming
📰
The 5 Levels of Front End Engineering (And Where Most Developers Get Stuck)
Learn the 5 levels of front end engineering to improve your skills and avoid getting stuck in a career rut
Medium · Programming
📰
Browser-Based PDF Editing with Vue 3 and pdf-lib
Learn to build a browser-based PDF editor using Vue 3 and pdf-lib, enabling users to edit PDFs directly in the browser
Dev.to · sunshey
Up next
How to Use Semrush Keyword Magic Tool with ChatGPT to Make Money
Grow with Will - SEO, Sales & Entrepreneurship
Watch →