How to css style more than one class tag at a time compound classes

Course contents
SECTION: 4
Project 2: Bike Repair Website 6:12:48
SECTION: 6
Project 4: Bootstrap Yogurt Website 3:35:39

Questions

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up

Course info

128 lessons / 17 hours 5 projects Certificate of achievement

Overview

Hi there, my name is Daniel Scott and together we’re going to learn how to build professional responsive websites. which look good on mobiles, tablets and desktop screens.

We will build 4 sites together...
  • a simple but elegant restaurant website.
  • a bike repair website. 
  • a responsive portfolio website.
  • a Bootstrap website.  

We cover everything you need to build your first website. From creating your first page through to uploading your website to the internet. We’ll use the world’s most popular (and free) web design tool called Visual Studio Code.

There are exercise files you can download and then work along with me. At the end of each video I have a downloadable version of where we are in the process so that you can compare your project with mine. This will enable you to see easily where you might have a problem.

We will delve into all the good stuff such as how to create your very own mobile burger menu from scratch learning some basic JavaScript and jQuery. 

 You will...
  • Learn how to work with responsive images and icons. and stunning full screen background images and probably one too many gradients. 
  • Learn how to create forms and to choose great fonts for your website. 
  • Learn how to work with Bootstrap 4 to easily add carousels, cards and complex looking menus. 
  • Setup a domain name with hosting so that your website is live on the internet for others to see.  

There are fun class projects for you to work on which will enable you to practice what you learn. By the end of this course you’ll have a great understanding of important web design topics like HTML5, CSS3, Flex box, Responsive design and Bootstrap.   

If that all sounds a little too fancy - don’t worry, this course is aimed at people new to web design and who have never coded before. We’ll start right at the beginning and work our way through step by step. 

Who am I? 

I’m Dan, and I’ve been building websites for about 15 years now. I am award winning instructor, and have won a MAX Master award for the last 2 years in a row at the prestigious Adobe Max conference.

Time to upgrade yourself?
Sign up for the course and let’s learn how to build responsive websites.

Course duration 16 hours 42 mins
Daniel Scott

Daniel Scott

Founder of Bring Your Own Laptop & Chief Instructor

instructor

I discovered the world of design as an art student when I stumbled upon a lab full of green & blue iMac G3’s. My initial curiosity around using the computer to create ‘art’ developed into a full-blown passion, eventually leading me to become a digital designer and founder of Bring Your Own Laptop.

Sharing and teaching are a huge part of who I am. As a certified Adobe instructor, I've had the honor of winning multiple Adobe teaching awards at their annual MAX conference. I see Bring Your Own Laptop as the supportive community I wished for when I was first starting out and intimidated by design. Through teaching, I hope to bring others along for the ride and empower my students to bring their stories, labors of love, and art into the world.
True to my Kiwi roots, I've lived in many places, and currently, I reside in Ireland with my wife and kids.

Certificates

We’re awarding certificates for this course!

Check out the How to earn your certificate video for instructions on how to earn yours and click the available certificate levels below for more information.

Downloads & Exercise files

Download Exercise Files Download Completed Files

Transcript

Hi everyone, we're going to take our menu in this video, that looks currently like this to, this, padding either sides, some space between them, font sizes. To do all this we're going to have to learn what a Compound Selector is. It's pretty cool, and nice and simple. It's going to allow us to be fancier Web Designers. Let's jump in and learn what it does. 

Okay, Compound Selector, What is a Compound Class? It's just more than one, we've got a problem now because, what I want to do is I want to style these A-tags. I want to turn off the underline, because I don't want it here, but I've already styled the A-tags. Remember, earlier on, we said, A-tags, we want to leave, we turned that off because we're like, actually we don't want-- we want to leave the underline. So we got one A-tag controlling a couple of things. So what we can do is use something cold Specificity. Just means the more specific you are, the more-- it will override if you're more specific. 

So if I say, generally all the A-tags do this, but if I say, the A-tags specifically in the Nav, do this other thing, that will win, because it's more specific. Generic, a little bit more specific, because we're saying the A-tags inside of the Nav. All right, let's just do it, Dan. In Visual Studio Code, the way you structure a Compound Class or a Compound Selector, compound, just because there's two parts to it. You can have more than one, we're just going to do one. So what we want to say is, we want to say, if there's a Nav with an A inside of it, you just put spaces between it, because we're dealing with Tag selectors, the Nav and the A, it's not a Class, we don't need the full stop. So that's all by themselves, with spaces in between them, and that's it. 

So if there's an A-tag inside of a Nav do this other thing. And what we want to say is Text Decoration is set to no deco-- Text Decoration set to none. There's none. Okay, cool. Semicolon, done, save. Let's have a little look; is that right? Does work; cool. So that one's left fine, but because that one says, the A-tag inside the Nav, you've got it. Compound Selectors, super useful. 

Now we did this way because it's the most simple way, and it's nice, clean and clear. You could have got rid of this. I'm going to wrap it up in my 'Command /' to comment it out. What I could have done is created a Class called No Underline. I'd like to show you both ways, because there's nothing really wrong with this way. And over here I'm going to say, Text Decoration is going to be set to 'none', and over here we could say, actually I would like, after the little, after the href thing, I'm going to put in a Class called, what was it called, No Underline. Save it, and hopefully just one of them will be working now. There you go. 

Now the trouble with that is that I have to apply that class to all of these tags, and that's fine, and if I make another one I have to go and add another class, and there's no real problem with it, but you can see the elegance of this first one; is elegance the word? I feel like it is. Awesome, we've learnt like what Compound Selector is, and the kind of syntax for it, spaces. 

Next thing I want to do is I want to tidy up the padding here. So centering in a box, centering horizontally is perfect, vertically is very hard, surprisingly hard. Don't ask me why, but it is. So later on in the course when we look at something called Flexbox, it will get easier, but for the moment at our current skill level, it's super hard. So what we're going to do is kind of fake it. We're just going to put some padding in the top and the bottom, until it looks like it's in the middle. 

The easiest way to do this, there's a couple of ways, but the way that we're going to do it is, let's add, we'll add some padding to this Nav, because at the moment it's right at the top, so we'll add a little bit to the top, a little bit to the bottom, and maybe get rid of the height. Let's give that a try, I'll show what I mean. 

So first of all let's get rid of the height. That will make it a bit clearer, so it's my Nav, height. We can either comment it out, or just delete it because I don't want it. See, it's kind of collapsed, but if I add some padding to the outside of the Nav, or I could add it the actual A-tags themselves, it doesn't really matter. We're going to do it to the Nav just because I feel like it. We're going to say 'padding', and we'll do 'padding top'. I'm going to make it 14 pixels at the top, and the same for the bottom. I'm just going to copy and paste it. Bottom. Awesome. Let's save it, let's preview in a browser. 

You can kind of see, we get to the same point, so it was collapsed, now this padding, pushing it out. If we did it with margins it wouldn't work, right? I just kind of drum this into you, the difference between margins and padding. Can you can see, there is some padding, there is 14 pixels above them, below there because if I crank it up to 140, you can see, there's lots of space there, but because it's the outside of the box it doesn't really do what we needed to do. So undo, undo, save, preview; nice. 

All right, let's fix up a couple of other things that are bugging me. Like the font size is a bit big, and the space between the menu, our buttons are tiny, so we need to adjust that. Let's jump into VS code. What should we do? We'll do it to the ‘Nav A’s, because I want to make this a font size of, what are we using? Font size of 12 pixels. I want it quite small to kind of match my design. Let's have a look, save, that's a bit better. 

Now let's do the space between them all. What we'll do is a little bit of padding, and it won't matter if it's padding or margin in this case, Padding Left. I'm going to put in 10 pixels. I'll do the same for the right, Padding Right. 10 pixels. Have a look; awesome. Why don't I do both? Because if I do that it's going to be slightly lopsided. It's going to look fine but it's going to push one side, and I guess it doesn't-- you can't really notice it on this. So imagine we've got a bit of padding to one side, but not the other on each of these. So it really, visually doesn't look any different, but you got padding either side now. I just kind of often do that, I just grab my cursor, and click over it, and drag, to try and highlight it, and gives me kind of a vague, just an idea of what's happening. 

So that's our basic kind of navigation. Don't go anywhere yet, we've got an Index page, we'd have to create a Menu page, and an Order Online page, but we've only made one so far, so just using those hashes or pound symbols, just to kind of make them active, but not actually make them go anywhere yet. All right, that is it for our really simple navigation. Let's get on to the next video.
  • Powered by Marvin
  • Terms of use
  • Privacy policy
  • © Bring your Own Laptop Ltd 2024