Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 2172

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 26, 20242024-11-26T02:58:07+00:00 2024-11-26T02:58:07+00:00

14. Styling

  • 61k

Width of keys

Current keyboard layout looks not realistic. E.g. space button is small like alt or ctrl.

How keyboard looks:

How keyboard looks

How keyboard should look:

How keyboard should look

If we look at the second image, or on a real keyboard, carefully, we'll notice that there are the primary keys: letters and numbers, and secondary keys: Tab, Backspace, Ctrl, Alt etc.

All primary keys have the same fixed width. But their number decreases from the top rows to the bottom. And the secondary buttons compensate for this decrease in number by increasing their width.

Rows 2 and 3 contain 13 primary keys and 1 secondary each. Backspace and Tab have the same width, and it is about 1.8 of primary key width. So we can say, that each row width is 14.8 units.

Row 4 contain 11 primary keys and 2 secondary. CapsLk and Enter have the same width:
(14.8 – 11)/2 = 1.9

Counting like this number of primary keys and width compensation of secondary keys in each row, and doing some approximation to achieve more realistic view, we get styling for the keyboard.

styles.css

/* specified keys */  /* 1st row */  .key.Backspace {     flex: 1.8; }  /* 2nd row */ .key.Tab {     flex: 1.8; }  /* 3d row */ .key.CapsLock {     flex: 2; }  .key.Enter {     flex: 2; }  /* 4th row  */ .key.ShiftLeft {     flex: 2.5; }  .key.ShiftRight {     flex: 1.5; }  /* 5th row  */ .key.Space {     flex: 8; } 
Enter fullscreen mode Exit fullscreen mode

With these styles our keyboard looks realistic.

Vertical alignment

Now the keyboard placed at the top of the screen. It's kinda asymmetric. Let's center it vertically.

Open developer tools: mouse right-click on the chrome page –> Inspect –> tab Elements (near the Console). Look at element nesting.

In order to center <div id="app"> we'll add to an element that wraps it (body) the style display: flex and other styles. We also add semantic tags: header, footer and main — good attributes of an internet page.

index.html

<body>     <header>         <h1>Keyboard Learning App</h1>         <p>             Read a tutorial for beginners on             <a href="">how to code this app from the scratch</a>         </p>     </header>     <main>         <div id="app"></div>     </main>     <footer>         <div class="socialLinks">             <a href="https://github.com/apayrus/keyboard">Github</a>             <a href="https://twitter.com/ApayRus">Twitter</a>         </div>     </footer>     <script src="./index.js" type="module"></script> </body> 
Enter fullscreen mode Exit fullscreen mode

styles.css

body {     display: flex;     flex-direction: column;     justify-content: space-between;     align-items: center;     min-height: 100vh;     margin: 0; /* by default body has margin 8px, we don't need it */     padding-left: 8px;     padding-right: 8px; }  header {     text-align: center; }  main {     width: 100%; }  footer {     text-align: center; }  a {     text-decoration: none; /* removed underline */ }  a:visited {     color: blue; }  .socialLinks a {     display: inline-block;     margin: 0.5rem; } 
Enter fullscreen mode Exit fullscreen mode

Result

Diffs in code 14

Entire code after the chapter 14

Congratulations

Thank you my dear friend, if you followed this tutorial until now. You spent a lot of time to learn all these things (14 chapters). Honestly, me too — to write it.

I hope this tutorial will help to newbies around the world. And the project itself will help to people to see how their languages all are fit into a single hardware keyboard with fixed number of keys. It unites us.

beginnersjavascripttutorialwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.