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.

https://i.sstatic.net/zqcua.png

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

Creating a reusable input for the Griddle settingIconComponent in a Meteor and React application

Kindly share if it is doable or not. If yes, then how? Main Objective - To swap out the settings button in griddle with a material ui button using Griddle version 0.6.1 Approach - Replace the settings button that displays a list of columns to choose from ...

Enhance the CSS Transition for a Seamless Bootstrap Toggle Menu Experience

I attempted to modify the Bootstrap Toggle Menu slide effect from top to bottom to left to right. You can view the website here: After experimenting with various CSS codes (I prefer using pure CSS for this effect), I finally discovered this one: .collaps ...

Show or hide a fixed position div using jQuery when clicked

I am new to jQuery and I am trying to create a "full page menu" on my own. However, I am struggling to hide the menu on the second click. I tried using .toggle() but I found out that it has been deprecated. Can someone assist me with this? Thank you so muc ...

Modifying the Header Background Color

Looking for help on my forum at The header background on my site needs fixing. I am trying to change the entire header background to match the color of the logo background, but I'm unsure what codes need to be adjusted. Can anyone provide guidance? ...

Looking to pass the router.query variable to the API URL call, but finding it undefined during the initial render

I'm encountering an issue with the API Call snippet below: const router = useRouter(); const { albumQuery } = router.query; const [albums, setAlbums] = useState([]); const fetchAlbumsHandler = useCallback(async () => { setIsLoading(true); ...

Place the div's scrollbar at the beginning of its content

Recently, I put together a custom CSS modal that includes a scrollable div (without the modal itself being scrollable). Interestingly enough, when I initially open the modal, the scrollbar of the div starts at the top as anticipated. However, if I scroll d ...

I'm encountering difficulties in automatically populating the category field from an API

Hey there! I have set up a signup form and I am trying to automatically fetch categories from the server API to populate an input area. Everything seems to be in place, but for some reason, I am unable to retrieve the data. API: Here is the code I'm ...

Setting the default value in setState in React Native allows you to initialize state

const fetchData = async (key) => { try { const jsonData = await AsyncStorage.getItem(key) return jsonData != null ? JSON.parse(jsonData) : false; } catch(error) { console.log(error); } } useEffect ...

Tips for effectively utilizing Formik's handleChange method multiple times to update a single value

Utilizing Material-UI along with Formik, I am trying to enable two input fields to modify a single value. The scenario involves having a TextField and a Slider where both inputs should have the ability to change the value for period. When assigning the sam ...

What is the best way to retrieve user groups in Django?

My goal is to investigate the user groups associated with a user in Django. However, when I check the console, I encounter the message: Uncaught ReferenceError: user is not defined at 6/:643:33 The purpose of the function is to redirect the user based ...

Would it be beneficial to create classes for frequently used CSS styles and apply them to HTML elements?

Check out my code snippet: style.css .bg-cover{background-size:cover; background-position:center;} .opacity-1{opacity:0.1;} .border-3-solid{border-width:3px; border-color: solid;} .black-border{border-color:#000;} .full-width{width:100%;} index.html ...

Having trouble with jQuery scrollTop not working after loading content with ajax?

When the html content is loaded via ajax, I need to scroll to a specific element. This element has the attribute data-event-id="". However, there are instances when the variable $('.timelineToolPanel[data-event-id="'+id+'"]').offset().t ...

Obtaining User Input in React JS within the Fetch Statement

I've written a code to fetch weather data from an API. Currently, the location is set to "chennai" in the link provided. I'd like to make this location user-dependent. How can I achieve this using React? import React,{useState,useEffect} from ...

Highlighting a specific list item dynamically without affecting its nested children

While I have come across similar questions, they don't quite address the specific issue I'm facing. My current project involves creating a keyboard-accessible tree widget. My goal is to apply a background color to the selected list item without ...

What is the best way to locate an item within a Redux array when working with TypeScript?

Below is the content of my slice.ts file. interface iItem { Category: string; Id: string; } interface iDataState { Items: Array<iItem>; } const initialState: iDataState = { Items: [], }; reducers: { updateItem: (state, action: PayloadAc ...

Adjust the Bootstrap settings to center the title on the navbar and shift the logout button to the right side

Is there a way to centrally align the title "My project" in the navbar while also keeping the logout button on the right of the same line as the title? <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="contain ...

Location-based services: Updating the position of a Google Maps marker without refreshing the entire map interface

How can I update only the marker on a map when the device is in motion or has increased accuracy? I want to reload the map when the position changes, but only move the marker. Below is the code snippet that I currently have: if (navigator.geolocation) { ...

Converting CSS code into JavaScript

I am currently working with the following code: .mr15 > * margin-right: 15px &:last-child margin-right: 0 I need help translating this code to Javascript. Should I use JQuery or pure Javascript for this scenario? Thank you. ...

Naming axes in Chart.js is a simple process that can easily be implemented

Greetings to all, I'm currently working on creating bar charts using chartjs...everything is going smoothly except for one thing - I am struggling to find a clean way to name my axes without resorting to CSS tricks like absolute positioning. Take a ...

React-native: Tried to redefine the property 'color'

My index.android.js file is giving me an error after navigating to login.js. How can I track down where this error is occurring? I've already run eslint, but it didn't detect any errors. /** * Sample React Native App * https://github.com/faceb ...