How to add a stretching background image to a website

This lesson is exclusive to members

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, it's time to replace our boring gray background with our exciting background image. It's cool, kind of stretchy, fits in there, covers all the background, looks neat. Not sure whatever we're eating but it kind of looks tasty. The irony, it's a vegetarian, but meat looks so good, especially in these kind of photographs. Anyway, let's get in and work out how to do the background. 

All right, to add our background image, it's a little bit strange, the previous video, or one of the previous videos we added our image. We added it to the HTML, and it appeared at the top of that document here, and it's great. The only trouble with adding it to your HTML is that you can't have things over the top, or at least not very easily. So, we want it in the kind of background, and we want it to be more of an effect, rather than something you can interact with, just kind of hiding at the back. It's more like a style. So we add it in the CSS styles. We do it here in styles.css, and we add it to, which one should we add it to? 

Remember our tag that covers the whole background, that we made gray? It's the same tag. So the Body tag here, we made gray, we can leave gray there. I leave the background color there normally, because sometimes it takes a little while for the image to load. So at least there's something in the background until it loads. The way to do it, it's well named, it's called background-image; nice. The one thing that isn't very clear is what to do next, and it's URL. It's one of those options in there.
 
So URL, so background image, URL, inside of that bracket, sorry, yeah, the brackets, you type where it goes. So it's going to be in images, forward slash, '/' and as soon as you have the forward slash in the CSS, it says, "Hey, do you mean this image, the logo?" and you're like, "No, not the logo." I want another image that I've used for the background. So I've saved it for you, it's in your Exercise Files. So you need to come out to your finder. Find your Exercise Files, find Project1. There's one in here called Background. I'm going to copy it, I'm using Command C on a Mac, Ctrl C on a PC. Desktop, I'm going to paste it into this Images folder, along with the logo. 

Now hopefully I can delete the forward slash, there you go. Type it back in, and it says, "Do you mean this guy?" You're like, "I do, that's the guy," or girl. Let's put in our semicolon, let's save, and let's see if it worked. And that might be enough, you might be like, "Done, move on", but if you're like me and you-- so at the moment, kind of doesn't do exactly what I want, you might like it, but at the moment I want it to kind of move. So if somebody's looking on a smaller screen, that image is still kind of centered. There's a really nice easy CSS class that we can use. Well, not class, attribute. So it is called background, another good one, background size. And there's one here called Cover. 

So background size cover will allow us to do that; let's give it a go. Resize. Oh, nice. See down the bottom there, it repeats, because the ratio of this thing is a bit weird. The image that we've got doesn't quite fit in there, so it has to do something, and at the moment it's repeating it. So let's have a look at getting rid of the repeat. It's going to be half our problem fixed, so we say 'background repeat'. So background repeat, I'd like to set it to no repeat, please. Awesome. Let's give it a go, and it's gone. 

This great box is there, you got to decide how much that annoys you, because the next thing we need to do is a little bit kind of strange. So to make this work, what you do is, the body's the tag we've been working with, right? but there is an overarching tag over everything, called HTML. And to make that go away, you've got to put in another tag just above it, and say, "I'd like the HTML tag to have a height of 100." Height of 100%. And that fixes that, I'm not even sure why. But that's what we do. Depends, like I said, sometimes in Web Design I can explain it to you and sometimes I can't. So there you go. It's covering, it fits, it's nice.

One more thing if you're getting picky is that, it's kind of centered and stays in there, but it's not quite centered, you're like, "Why aren't you quite centered?" You can mess around with the background, what is it called, background align. Have I spelled it all right, background alignment, no it's background, man, can't-- position, that's it. So background position, and we type in center, semicolon, ';' And that should fix that. So now instead of-- it will go from the center, rather than kind of left and right. Yeah, I like it. Now one thing, if you are following along on a really small screen, you're like, "I can't even make it do it that, Dan." It's true, I just thought of it then, I'm like, if you have a really small screen it's going to be, very hard to like drag it out big enough, to make it do all the kind of resize bits. That's something to know. 

I guess what you're doing then, for like-- you probably can get away with pretty much all of that gone. The trouble will be, is when somebody like me with a giant screen opens it up, and goes, "Hey it's looking, not looking nice." So if you are working on a really small laptop, and you're like, "I can't even test this stuff," later on in the course I'm going to show you how to fake being a really big screen, but yeah, I just thought I'd add that there, just in case you're like, "Can't make that work." But it is potentially necessary. All right, background images, done and dusted.
  • Powered by Marvin
  • Terms of use
  • Privacy policy
  • © Bring your Own Laptop Ltd 2024