W04 Code-along Activity: Home Page Layout Enhancements
Code-along Activity Overview
For this activity, you will code along with an instructor video that walks you through each step of the activity below. Make sure that you pause the video, or watch sections over if you need to, so that you are able to complete the entire activity.
Your instructor will post a link to the video in Microsoft Teams.
Overview
Follow the code-along video to enhance your course home page's layout.
Instructions
- Open your course home page, index.html, and stylesheet styles.css, for editing.
- Refactor the CSS for the combined rule of
header,footerto have a maximum width of 840 pixels and to center the content on the page. You will add in the main section later.Check Your Understanding
header, footer { max-width: 840px; margin: 0 auto; }This means you should delete the
max-widthdecoration fromheader,main, andfooterselectors if necessary. - Use CSS Flex to make the navigation links display horizontally across the
screen. The menu should be justified with even spacing and centered within the navigation
bar. Remember to apply the CSS Flex declaration to the container.
Check Your Understanding
nav { background-color: steelblue; padding: 1rem; display: flex; justify-content: space-evenly; align-items: center; } - If you have not already added a link to your LinkedIn profile (or to LinkedIn in general)
and to
your Facebook profile (or to Facebook in general), add those links to the
navnavigation menu. - Alter the anchor tags to be block elements with padding and no text decoration. You are
free to apply other relevant styling as well.
Check Your Understanding
nav a { display: block; padding: 0.5rem; text-decoration: none; font-size: 1.2rem; font-weight: 700; color: #fff; /% shorthand for white %/ } - Add a bottom border to the heading
h1element. - In your HTML file, encase the
mainandasideelements in adivelement with aclassattribute named "grid". - In your CSS file, add the
.gridselector to theheader, footerCSS selector to also make it part of themax-widthandmargin.header, .grid, footer { - Make this new
diva CSSgriddisplay with theasideon the left and themainelement on the right as shown below.There are at least two ways to do this. Choose one. Not both.
- Use
grid-template-columnsto define the columns and their widths. - Use
grid-columnandgrid-rowto define the grid items (main and aside) position.
Check Your Understanding
.grid { display: grid; align-items: center; } main { grid-column: 2/3; margin: 1rem; } aside { width: 20rem; position: relative; grid-column: 1/2; grid-row: 1/2; }Note that the
asideselector needs to apply thegrid-rowwhereas themainselector did not. This is because of the order in the HTML structure. - Use
Testing
- Check your page against the development standards checklist.
- Check for color contrast violations at the AA level using the DevTools CSS Overview tool.
- Commit and sync your changes to your wdd130 GitHub Pages enabled repository.
- View your published HTML file in a browser to verify that everything has worked correctly.
Hint: The published URL will be located at
https://yourusername.github.io/wdd130 - Validate the HTML and CSS of your rendered page
- Post any questions you have in Microsoft Teams in the Week 04 Forum channel.
Alternative Video Link
In addition to the link that your instructor posted, you are also welcome to watch the following code walkthrough or use its transcript:
Submission
Please pause and re-watch any sections of the instructor video necessary until you have completed the entire activity and your page is similar to the instructor's. When you are finished:
- Return to Canvas to take the quiz.