Tips for showcasing cards in a horizontal inline layout

Hello everyone! I'm currently working on creating dynamic cards, but I'm having trouble displaying them inline. I'd like to arrange the cards horizontally with a scroll bar.

I want to make them display in horizontal line

<div className='scrollmenu d-inline'>
                {
                    data.map((user, index) => (
                        <div >
                            <div className="card text-center" style={{ width: 10 + 'rem' }}>
                                <img className='m-auto mt-2' src={user.img} alt="Avatar" style={{ width: 100 + 'px' }} />
                                <a href="#home">{user.name}</a>
                            </div>
                        </div>
                    ))
                }
            </div>

Here is some CSS code:

div.scrollmenu {
    background-color: #333;
    overflow: auto;
    white-space: nowrap;
  }
  
  div.scrollmenu a {
    display: inline-block;
    text-align: center;
    padding: 14px;
    text-decoration: none;
  }
  
  div.scrollmenu a:hover {
    background-color: #777;
  }

  img {
    border-radius: 50%;
  }

Answer №2

To start, eliminate the parent div from the div.card section, Next, add the following css to the div.card ->

div.card {
 width: 300px;
 display: inline-block;
}

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

How can you customize the appearance of the Input component that wraps the Select in Material UI for React?

Here is an example of my JSX code: <FormControl> <InputLabel>My label</InputLabel> <Select> ... </Select> </FormControl> When using the classes prop to style elements within the FormControl and Select, I enco ...

When trying to start a React project with npm, an error message is displayed stating "index.js file cannot be located."

I've been working on a React project using VSCode, but every time I try to run it in the browser, I keep encountering an error stating that it can't find the index.js file, even though it's located in the correct folder. (Yes, I made sure to ...

The shared module for next/router is not found in the shared scope default within Next.js and @module-federation/nextjs-mf

I am working on a JavaScript Turbo repo with a host app that has the following configuration in its next.config.js: const { NextFederationPlugin } = require("@module-federation/nextjs-mf"); const nextConfig = { reactStrictMode: true, ...

Using React.Js along with Framer Motion, the animations will trigger solely upon the initial loading of

I'm currently developing a React project that involves animating components as they scroll into view using Framer Motion. However, I'm facing an issue where the animation triggers every time I scroll past a component, even if it has already been ...

Calculating remaining change with the modulus operator in JavaScript

I have a task where I need to convert any given number of pennies into the correct amount of Quarters, Dimes, Nickels, and leftover pennies. My program currently uses Math.floor() to calculate the total value of each respective coin type when executed in ...

How to retrieve the dimensions of an image for a specified CSS class with Selenium or PIL in Python

I am interested in using Python to determine the size of specific images. Is it possible to automate this process so that I can identify only images with certain classes? I am unfamiliar with PIL. Could I define the CSS class/name/id after specifying the U ...

The jQuery toggleClass() function is not being applied successfully to content that is dynamically generated from

I've created an awesome collection of CSS-generated cards containing icons and text with a cool animation that expands upon tapping to reveal more icons and options. I carefully crafted the list to look and behave exactly how I wanted it to. But now, ...

What is causing the Type error to occur when trying to fetch a URL from a Swiggy restaurant's

What could be causing a Type error when trying to fetch a URL from a Swiggy restaurant? async function getRequest() { fetch('https://www.swiggy.com/restaurants/meghana-foods-5th-block-koramangala-bangalore-229') .then( res => res.json( ...

Tips for using the populate function within a deeply nested object

Within my user schema, there exists a field structured in the following manner: courseTaken: [ { course: { type: mongoose.Schema.Types.ObjectId, ref: "Course", }, rating: { type: Number, min: ...

Showing the outcome of a PHP function within a div container

While working on my WordPress site, I've implemented user registration and login functionality. However, I'm not a fan of the default 'admin bar' and would rather create a custom navigation bar. I am looking for a way to dynamically loa ...

Get the value of an HTML element

Is there a way to retrieve the value of an HTML element using PHP or JavaScript, especially when the value is dynamically loaded from another source? I have tried using jQuery with the DOM ready event, but often encounter the issue where the element's ...

Attention: validation of DOM nesting encountered an error: element <div> is not permitted to be nested inside <p>

I am facing the issue of not being able to find a solution to a known problem. The paragraph in question must not contain any other tags, yet I did not use any paragraph tags in my case. return ( <div className={classes.root}> <Stepper acti ...

Ways to align text in the middle and shift it downward?

I'm currently attempting to center the bottom navigation bar using the following CSS code: #main-nav { margin-left: auto; margin-right: auto;} Unfortunately, this method is not achieving the desired result. I even tried adding <center></cen ...

Issue with reactivity not functioning as expected within VueJS loop without clear explanation

Struggling with implementing reactivity in vue.js within a loop? The loop renders fine, but firing an event updates the content without visibly rendering the data on the page. The latest version of vue.js is being used with bootstrap and jquery. Despite a ...

Utilize an Ajax function to call the BOT listening URL within a Web method

My recently developed web application features a submit button that triggers an Ajax call to communicate with the BOT. The code snippet used for the Ajax function is as follows: <script> $(document).ready(function () { $("#btnSend& ...

``There seems to be an issue with implementing the SlideDown feature in JavaScript

I am having an issue with a code where the expected behavior is to slide down a div when a person hovers over text, but it's not working. Can someone please review and identify the cause of this problem? <script type="text/javascript" src="/js/jqu ...

Changing the identification of elements

I noticed that when I open object X and Y, they have the same fields, tabs, and checkboxes. However, I am confused as to why the IDs of the checkboxes and other elements are different. Can you explain what gwt-uid(number) means? Please take a look at the a ...

React Native reminder: Unable to update React state on a component that is unmounted

I am seeking clarity on how to resolve the issue in useEffect that is mentioned. Below is the data for "dataSource": [{"isSelect":false, "selectedClass":null, "zoneId":1026, "zoneName":"tomato"}, ...

Links are causing pages to freeze

I have a collection of diverse pages, each requiring specific data from a database to load. I am seeking assistance in automating the import process, list creation, and route setup. Additionally, I need help with selecting and highlighting drawer items bas ...

How can I append a query parameter to the URL in NextJS?

My goal is to include a query parameter whenever I enter some text in an input field and press the ENTER key. However, I'm struggling to determine the correct placement for this query parameter to function properly. Essentially, I want my URL to show ...