Giter Club home page Giter Club logo

news-homepage's Introduction

Frontend Mentor - News homepage solution

This is a solution to the News homepage challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page

Screenshot

Desktop: Desktop initial state

Mobile:

Mobile initial state

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first workflow

What I learned

  • I learned how to create a responsive navigation bar using only HTML and CSS. The solution boiled down to a few parts: a media query, an HTML checkbox input and labels, and some styling. For the media query, anytime a screen of size less than 800px is detected it will show the mobile navigation bar. Otherwise, it will show the desktop navigation bar. For the HTML checkbox, we hide it from the display but have a label element (of a hamburger icon) that will be visible. When the hamburger icon is clicked, it will change the state of the checkbox to "checked" and that will cause the mobile navigation menu to transition in from the right side of the screen. When the close icon is clicked, it will remove the "checked" state from the checkbox and cause the mobile navigation menu to transition out of the right side of the screen.

  • I learned about the general sibling selector in CSS and how it can be used to change the styles of elements that are next siblings of a specified element. This selector is especially helpful when you want the state of one element (ie. checkbox checked) to affect the styling of a sibling element, as opposed to using JS. Ex. When the checkbox is checked, the sibling with class="links-container" will have a horizontal positioning of 0 from the right.

#nav-checkbox:checked ~ .links-container {
    right: 0;
}
  • I learned how to use the CSS Grid Layout. The reference images for non-mobile screens looked like it would be a perfect candidate for grid since I could see three columns and three rows. I was able to break the page accordingly by specifying to the grid's template columns to create three columns with a size of 1fr:
.page-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
} 

Continued development

It was great to finally learn and implment the very basics of the Grid layout for this challenge. There is still much to learn about this layout and that is something I will look into for future challenges.

Useful resources

Author

news-homepage's People

Contributors

ianwilk20 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.