Check out the slides first before proceeding.
-
Open accessories.html and add following element in the head section.
<link rel="stylesheet" type="text/css" href="style.css">
-
Open style.css
-
Create a body selector.
-
Add background-color property.
body { background-color: black; }
-
Check if website color changed.
-
Use browser developer tools to find out the banner's hex color code.
-
Change the value of background-color to the Hex code.
-
Create a class named container above earring image element.
<div class = "container"> <img src = "earrings.jpg" alt = "Diamond Earings">
-
Close the container below the Order button element.
</button> </div> </div>
-
Open style.css and add container class as a selector, create a 10px border.
-
Set the width to 285px and padding to 60px and see what happens.
.container { border: 10px solid block; width: 285px; padding: 60px; }
-
Remember, to center elements you only need to use display and margin properties.
display: block; margin: auto;
-
Add these two properties into container class.
-
Refresh the page and the find the container in the middle.
-
Next step is to center the items inside the container.
-
Create a selector that selects everything inside container.
.container * { display: block; margin: auto; }
-
Refresh the page and see the elements inside the container centered.
-
Notice that the 'Click here' link has became a block element.
-
To fix that, select 'a' in container and set it to inline.
.container a { display: inline; }
-
First step, open accessories.html file and locate the table element.
-
Set the table border to 0.
<table border = "0" style = "text-align: center;">
-
Meanwhile, remove the colons ':' from the table labels.
-
Now go back to style.css.
-
Locate container class and set the background-color to white.
-
Add border-radius property with a value of 20px to change the four corners of the card to rounded.
.container { ... background-color: white; border-radius: 20px; }
-
Next, remove or comment the border property.
-
Add a box-shadow property with the following values.
.container { ... border: 1px solid white; box-shadow: 2px 6px 25px rgba(0,0,0,0.1); }
-
In RGBA, RGB - Red, Green, Blue. A stands for Alpha. It is used for setting the opacity of the color.
-
Now we can add some extra padding to the paragraph and image elements to make it look cleaner.
.container p { padding: 30px 8px; } img { padding-bottom: 40px; display: block; margin: auto; }
- Open orderForm.html and link to style.css.
- Copy the same banner(change to max-width:100% in both pages) from accessories.html to show consistency.
- Some tips:
- You don't need to touch the CSS file, just repeat steps 1 & 2 of Part 2.
- To fix the messy form elements, take a look at step 8 of Part 3.
-
Let's go back to accessories page.
-
Take a look at the order button, there is an underline because it is a link.
-
Also notice that only the link can be clicked, where the rest of the button area is unclickable.
-
To fix this, go to accessories.html and scroll to the bottom to locate the button element.
-
The mistake is that the button element is containing the link element.
-
Change both the elements as below:
<a href = "orderForm-done.html"><button type = "button">Order</button></a>
-
To remove the underline, go to style.css and locate .container a that you created in step 8 of Part 3.
-
Add in a new property called text-decoration and set the value to none.
.container a { ... text-decoration: none; }
-
Now that the button is fixed, we can start adding some colors to it.
-
First, add a button selector in style.css.
-
Add padding with the value of top/bottom: 15px, left/right: 30px.
-
Set the border-radius to 10px.
button { padding: 15px 30px; border-radius: 10px; }
-
Next, remove the border and set a background-colorto the button
-
Add shadows to the button to make it pop out.
button { ... border: 0px; background-color: #FFB0BE; box-shadow: 1px 4px 6px rgba(0,0,0,0.1); }
-
Change the font color, weight and size.
button { ... color: white; font-weight: bold; font-size: 13px; }
-
Now, let's add a mouse hover effect on the button.
-
Create a new button:hover selector.
-
Copy the box-shadow property from Step 6 and set it wider and darker.
button:hover { box-shadow: 1px 4px 16px rgba(0,0,0,0.2); }
-
Before duplicating the item, create a items-container div class that contains all the items.
-
To avoid any hassle, you should fold your code in Sublime Text.
-
First, locate the container class, it is under banner image.
-
Move your cursor to the line number, very left side of the editor.
-
An arrow will appear, click the one next to container class and it will collapse everything inside.
-
Now, you can add the items-container class without scrolling all the way to the bottom.
<div class="items-container"> <!-- container class starts here --> <div class="container"> ... <!-- container class ends here --> </div> </div>
-
You can easily duplicate the items now, just highlight the container class, copy and paste.
-
After you're done, you will notice that the items sorts in only one column.
-
To fix that, go to style.css and locate container class, change display value to inline-block.
-
Also, change the margin from auto to 10px.
.container { margin: 10px; display: inline-block; /* allows the element to have height and width but still acts as inline */ ... }
-
All the items will move to the left now, to center it, use the items-container class you've created.
.items-container { text-align: center; }
-
Go to accessories.html and scroll to the bottom, add a footer tag above the closing body tag.
... <footer><p> Copyright © Sunway Tech Club 2018 </p></footer> </body>
-
Go back to style.css and create a footer selector.
-
Add background-color, height, color and text-align properties.
-
Set it as a block display and add some paddings at the top.
footer { background-color: #394258; height: 70px; color: lightgrey; text-align: center; display:block; padding-top: 90px; }
-
Notice the footer did not fill to the edges of the page, to fix this, go to style.css.
-
Scroll to the top and add a margin property with a value of 0 in the body selector.
body { ... margin: 0; }
-
Now let's add social media icons to the footer. Open accessories.html and add this in the head section.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
-
The link element above links to an external CSS file from an online source.
-
Now, scroll down to footer section and add these classes inside.
<footer> <a class="fa fa-facebook"></a> <a class="fa fa-instagram"></a> <a class="fa fa-twitter"></a> <p>Copyright © Sunway Tech Club 2018</p> </footer>
-
Always leave changing fonts to the last so you can have time to pick the font you prefer.
-
Go to fonts.google.com to look for fonts.
-
Some fonts don't look good in paragraph so make sure you select paragraph to check.
-
I have chosen Alegreya Sans for this demonstration, click the red 'plus' logo at the top right corner.
-
There will be a bar at the bottom, click to open it and select @import.
-
Copy the link and paste it at the top-most section of style.css.
-
Then, add font-family property in body selector to apply the font.
@import url('https://fonts.googleapis.com/css?family=Alegreya+Sans'); body { ... font-family: 'Alegreya Sans', sans-serif; }
-
Congratulations! You have completed all the parts.