Skip to content

leo-jp/single-price-grid-component

Repository files navigation

Frontend Mentor - Single price grid component solution

This is a solution to the Single price grid component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Note: Delete this note and update the table of contents based on what sections you keep.

Overview

The challenge

Users should be able to:

  • View the optimal layout for the component depending on their device's screen size
  • See a hover state on desktop for the Sign Up call-to-action

Screenshot

See more designs here. Desktop Preview

Links

My process

Built with (in-order)

  • Semantic HTML5 markup
  • CSS & SCSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first design workflow
  • Bootstrap

What I learned

Import basic css
<head>
  <link rel="stylesheet" href="<path>/bootstrap/dist/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="<path>/bootstrap/dist/css/bootstrap-grid.min.css"/>
</head>
Import basic javascript
<body>
  <script source="./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  <script source="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
</body>  
Sticky Footer
  • Bootstrap v.5 sticky footer
  • Key Points for a better display of footer
    • Using flex and flex-shrink
    • Using footer & container class
    • d-flex flex-column: set to vertical direction.
    • flex-shrink-0: element will not shrink
<!--This type of HTML structure does not let footer overlap the main contents-->
<!doctype html>
<html lang="en" class="h-100">
  <head>...</head>
  <body class="d-flex flex-column h-100">
    <main class="flex-shrink-0"> 
      ...
    </main>
    <footer class="footer mt-auto py-3 bg-light">
      <div class="container">
        ...
    </footer>
  </body>
</html>
Force columns to break to new line
 <div class="w-100"></div>
Stacking divs horizontally & centering a container followed by custom css
<div class="container-fluid container-component">...</div>

Sass/Scss & CSS

  1. npm install sass or yarn add sass
  2. add the script in package.json to compile & run sass
  3. To compile and run: npm run scss or yarn run scss
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "scss": "sass --watch <scss>:<css>"
  },
  1. node-sass: Refers to the node-sass package.
  2. --watch: An optional flag which means “watch all .scss files in the scss/ folder and recompile them every time there’s a change.”
  3. styles/scss: The folder name where we put all our .scss files.
  4. -o styles/css: The output folder for our compiled CSS.
Getting started with Sass
CSS Grid System Classes

The Bootstrap grid system has four classes:

  • xs (for phones - screens less than 768px wide)
  • sm (for tablets - screens equal to or greater than 768px wide)
  • md (for small laptops - screens equal to or greater than 992px wide)
  • lg (for laptops and desktops - screens equal to or greater than 1200px wide)
Sass/Css Media Queries

Rule of thumb: to apply the style based on device's width/height, use the same structure as is!

div.main {
  &.sub {
      // default style 
  }
}

@media <option> <condition> and ( <width/height> ) {
  div.main {
    &.sub {
      // new style
    }
  }
}

Github

Continued development

  • Do mobile-first design development
  • Add data connection, routers, and state management using ReactJS, VueJS, etc.
  • Enable database connection and associate it with Javascripts.
  • Follow Web security best practices

Useful resources

Author