Can anyone suggest a way to change the orientation of mapped items from column to row?

In my React app, I am creating a keyboard using the following component:

Keypad.js

const Keypad = () => {

    const letters = [
        'Q',
        'W',
        'E',
        'R',
        'T',
        'Y',
        'U',
        'I',
        'O',
// etc
    ]

    return(
        <div>
            {letters.map((letter,index) => {
                return(
                    <div className="keyboard-container" key={index}>
                        <div className="key">{letter}</div>
                    </div>
                )
            })}
        </div>
    )
}
 
export default Keypad;

I am facing an issue where all the letters are being rendered in a single column instead of rows. How can I correct this problem?

Below is the CSS code used:

.keyboard-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

.keyboard-container .key {
    width: 60px;
    height: 60px;
    background-color: #69696d;
}

I have attempted to add inline styles in Keypad.js and also tried utilizing a grid system to organize the items.

Answer №1

After some troubleshooting, I finally found the issue - the keyboard-container class was mistakenly placed in the incorrect location:

    return(
        <div className="keyboard-container">
            {letters.map((letter,index) => {
                return(
                    <div>
                        <div className="key">{letter}</div>
                    </div>
                )
            })}
        </div>
    )
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

unable to properly assess the functionality of the timeout feature within the useEffect hook

I've been working on a lazyload image loader component that only loads images if they have been visible for more than 500ms. Although the functionality is working as expected, I'm facing challenges when it comes to writing a test to validate its ...

The parameter type SetStateAction<MemberEntityVM[]> cannot be assigned the argument type Promise<MemberEntityVM[]> in this context

I am looking to display a filtered list of GitHub members based on their organization (e.g., Microsoft employees). Implementing React + TS for this purpose, I have defined an API Model which represents the structure of the JSON data from the GitHub API: ex ...

I'm curious if there is a method to modify layouts in NextJS 14

In my NextJS 13/14 app, I have a standard setup where I use a layout.tsx file to display a sticky navbar for navigation: import "./globals.css"; export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) ...

Enabling a JSON file property to be clickable as needed

I am working with a JSON file obtained from an API call, which contains various objects. My goal is to display the message property of each object, some of which may contain hyperlinks within the message. Here is the HTML code I have implemented to make t ...

Is it possible to copy text from an iframe to the clipboard?

I have encountered an issue in my React app where I am trying to copy text from a card when the user clicks on it. The app displays multiple cards by looping through an array, so there can be any number of cards (n). The problem arises because the React a ...

React is throwing an error due to an unhandled rejection: Request did not succeed, status code 404

import React, { useEffect, useState } from 'react'; import axios from 'axios'; const PokemonApi = () => { const [selectedPokemon, setSelectedPokemon] = useState(); useEffect(() => { ...

Converting HTML and CSS to PDF in Java using iText

I've been working on converting HTML to PDF. Initially, I transformed my HTML code into XHTML using the resources provided in this link: After successfully displaying the generated XHTML code in a browser by creating an HTML file for testing purposes ...

-moz-box-reflect - Styling for FireFox

I've been attempting to achieve a similar effect to this tutorial at http://designshack.net/tutorialexamples/HoverEffects/Ex5.html. However, I'm encountering issues with getting the reflection of the image to display properly in IE and Firefox. H ...

Tips for transferring the id from a delete button to a delete button in a popup dialog box

In my frontend application, there is a table where each row corresponds to an item. For every row, there is a "Remove" button that triggers a warning popup upon being clicked. The intention is to pass the item's ID in this popup so that if the user co ...

Express Form Validation: Ensuring Data Accuracy

I have recently learned that client-side form validations may not be sufficient to prevent malicious actions from users. It is recommended to also validate the form on the server-side. Since I am new to using express, can someone provide guidance on what s ...

Adjusting the size of images in a Bootstrap lightbox gallery

I am currently working on a website for an artist, making the galleries a key aspect. The website is built using Bootstrap, with the Lightbox for Bootstrap plugin being used for the galleries. Everything seems to be working well in terms of adjusting the i ...

Attempting to display images in various formats using the Picture HTML element

Vue is being used to create a dynamic picture component, resulting in the following code: <picture style="display: contents;"> <source type="image/avif" sizes="700px" src ...

problem with nivo slider causing content to overflow

My webpage is using nivoslider to display images. However, I am facing an issue where the images are overflowing one by one until the page fully loads. I have tried setting the overflow:hidden property in the CSS but it doesn't seem to correct the pro ...

The hamburger menu appears to be missing when viewing in Safari, while it functions properly on both Chrome and Firefox browsers

My website has a responsive menu that functions perfectly in Chrome and Firefox, but encounters issues in Safari on mobile devices. The site is built using Elementor WordPress and I believe adding some -webkit- properties could solve the problem, but I&apo ...

State in Angular stubbornly refuses to switch despite condition changes

Here is the Typescript code, followed by the HTML: public verifySelection() { let choice = false; if (typeof this.formUser.permissionsTemplateID === undefined) { choice = true; } return choice; } <div class="form-group" ...

PHP: Parsing HTML Tables with Headers and Irregular Body Rows Using Simple HTML Dom Parser

In an HTML table, the data is structured as follows: Header 1 has Row 1, Header 2 has Row 2 and Row 3, while Header 3 has Row 4, Row 5, and Row 6. <table> <thead> <tr> <th>Header 1</th> </tr> </thead& ...

Achieve a fading effect on an element as you scroll down the page

I successfully implemented a toggle audio button on my website, but now I would like it to fade in along with the scroll-to-top button that I also have (which operates similarly to the buttons on scrolltotop.com). Is there a simple way to achieve this? He ...

Relocate the form element from its current position inside the form, and insert it into a different div

I have a sidebar on my website with a search/filter form. I am attempting to relocate one of the elements (a sort order dropdown) from this form, outside the form using CSS/JS and display it inside a div on the right side. Is it possible to do this without ...

Error encountered in Django when attempting to pass an SQL query due to an UnboundLocalError

When I encountered an issue: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/mainpage.html Django Version: 3.2.12 Python Version: 3.7.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth' ...

Header reference differs from the document referrer

this is the request header: GET / HTTP/1.1 Host: localhost:3002 Connection: keep-alive sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96" sec-ch-ua-mobile: ?0 User-Agent: ...