Posted in how to
4576
4:14 am, January 21, 2020
 

How to do a simple bootstrap landing page from Scratch - Part 2

So in Part one of this tutorial we created a bare bones html file which is the basis of our landing page.

The code should look something like this, so far. (I will provide download links at the end of the tutorial for all the files)

Lets drag that into a browser and see how it looks.

Yep, pretty blank so far, but this is the base, which includes all the elements from bootstrap, so dont worry. Now we will go and add some pre-built elements from bootstrap.

Let’s start at the top with the header.

Lets add a nav bar to the top using this element:

https://getbootstrap.com/docs/4.4/components/navbar/

Now we can reload the browser and see that we have a nice header added to our landing page.

Since we are just doing a “Simple” landing page, we will just leave the nav simple as well, and change the title to our landing page title.

Hero Image

Now to add a nice Hero image, underneath our Header. This breaks up the page a bit, and makes it more “visually appealing” or something. Better than all just white anyway.

Head over to a nice stock image site and pick an image, a few of my favourites are pexels.com or unsplash.com.

Save the selected image into our working directory, under a new directory called images.

Create a new div element called home-hero. Like so:

And add some styles for this div element, up in the header in a new style tag. I add them into the header for now, as we shouldn’t have too many additional styles. If you start adding heaps then it might be better to add them to an external style sheet. But we won’t worry about that for this tutorial.

Now we have a div element and a style tag that is attached to it. We can set our new image to be the background of this element.

I cropped out the last bit of this which should be center no-repeat; and also add the line, background-size: cover; which will make the background image cover the size of the home-hero div element.

Save (CTRL+S) the changes and let’s have a look and see if that worked…

Yep looking good so far.

Snazzy…

Ok should we add the hero text in the middle of the hero image? I guess so, or could add below it. We will go in the middle for now.

We will just use the built in bootstrap font for now and see how it looks.

Add some hero text and a new element for the title.

And add a class so we can style it.

This will probably be aligned to the top as well so will need to pad it up a bit.

Yeah i cant type font-size in that one for some reason.

Reload and have a look again.

Not too bad, just need to change the text a bit. You can do this using chrome dev tools, or just change the values in the css, depending on how interactive you want to be.

Here is an example using chrome dev tools, in chrome you can access this using F12 and then click on the inspect arrow to select your element.

Make sure you copy the new rule and paste it back into your style sheet index.html file, or it will not work…

Also i noticed the JS error here, as bootstrap does still require jquery to work. Not that we will actually be using any of the JS for the moment its good not to have any console errors.

So back to cdnjs.com and find the js link for JQuery, add that above the bootstrap js down the bottom of our file.

This should get rid of the jquery requirement error in the console.

Ok now onto the next part. Three Boxes with icons and all that stuff…

Actually, man i’m tired after that last part i might go get a snack or something. And i will add the Three boxes to Part 3 of this tutorial!

Yay! :P

Download

You can download this article as a PDF here. Click to Download How to do a simple bootstrap landing page from Scratch - Part 2 as PDF

View Statistics
This Week
99
This Month
450
This Year
409

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Articles
Search Articles by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote

"Olivia, my eldest daughter, caught measles when she was seven years old. As the illness took its usual course I can remember reading to her often in bed and not feeling particularly alarmed about it. Then one morning, when she was well on the road to recovery, I was sitting on her bed showing her how to fashion little animals out of coloured pipe-cleaners, and when it came to her turn to make one herself, I noticed that her fingers and her mind were not working together and she couldn’t do anything. 'Are you feeling all right?' I asked her. 'I feel all sleepy,' she said. In an hour, she was unconscious. In twelve hours she was dead. The measles had turned into a terrible thing called measles encephalitis and there was nothing the doctors could do to save her. That was...in 1962, but even now, if a child with measles happens to develop the same deadly reaction from measles as Olivia did, there would still be nothing the doctors could do to help her. On the other hand, there is today something that parents can do to make sure that this sort of tragedy does not happen to a child of theirs. They can insist that their child is immunised against measles. ...I dedicated two of my books to Olivia, the first was ‘James and the Giant Peach’. That was when she was still alive. The second was ‘The BFG’, dedicated to her memory after she had died from measles. You will see her name at the beginning of each of these books. And I know how happy she would be if only she could know that her death had helped to save a good deal of illness and death among other children."

I just checked google books for BFG, and the dedication is there. 

https://www.google.com.au/books/edition/_/quybcXrFhCIC?hl=en&gbpv=1 


Roald Dahl, 1986
Random CSS Property

invert()

The invert() CSS function inverts the color samples in the input image. Its result is a <filter-function>.
invert() css reference