Exercises: Navigation Bar
Exercises: Navigation Bar
Exercises
Navigation Bar
Create a navigation bar similar to the image below. Read the next page for the
details.
Mobile
codewithmosh.com
Layout 2
Hints
1. Open /Solution/NavBar/index.html to see the final result.
2. Launch Chrome DevTools. On the Elements tab, click on the Toggle Device Mode icon
to go to the device mode.
3. Click on various parts of the the device bar on the top to view the layout on different
screen sizes.
4. As you can see, on mobiles, the items are listed vertically and are center-aligned. On
tablets and wider screens, they are listed horizontally and pushed to the end of the
navigation bar.
5. Build this navigation bar from scratch using the mobile-first approach. Make the
browser small or use the device mode in DevTools to ensure the navigation bar has
the right look and feel on mobile devices.
6. To change the default font, apply the following style to the body element. We’ll talk
about fonts in detail later in the course.
7. Use media queries to re-style the navigation bar for tablets and wider screen. You can
use 768px as the breakpoint. That’s a standard breakpoint for tablets.
8. Once you’re done, compare your HTML/CSS with mine. It’s almost impossible that
your solution would be identical to mine, and that’s totally expected. We all think
differently. As long as your solution works, you’re on the right track. Study my
HTML/CSS code to see if there are areas you can improve your implementation.
codewithmosh.com
Layout 3
Photo Gallery
Create a photo gallery similar to the image below. Read the next page for the details.
codewithmosh.com
Layout 4
codewithmosh.com
Layout 5
Hints
1. Open /Solution/PhotoGallery/index.html to see the final result.
2. Use the Device Mode in DevTools to view the layout on various screen sizes.
3. Note that on mobile, we have a single column. On tablets, we have two columns. On
laptops and wider screens, we have three columns and the third image takes up the
space of four images.
7. You can represent the container for the images using a div or a ul element. It’s up to you.
8. To make the images fit the containing cell, you should give them a width of 100% and set
their object-fit property to cover so they don’t get squashed.
9. Once done, compare your implementation with mine.
codewithmosh.com