In the Bootstrap Grid system, all posts are aligned to the left side

I have created a gallery with Bootstrap in React.js. The posts are currently displayed using the bootstrap grid system, however, all posts appear on the left side and I am struggling to center them. Any ideas on how to achieve this?

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

After applying justify-content-center

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

After removing margin: 10px; from .top_post

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

After removing width: 250px; from .top_post CSS

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

xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CSS

.top_hello {
  text-align: right;
  margin: 20px 0 0 0;
}

.top_search {
  margin: 20px 0 20px 0;
  justify-content: right;
}

.top_search_input {
  display: flex;
  margin-right: 0;
  margin-left: auto;
}


.top_post {
  /* position: relative; */
  background:lightgreen; 
  padding:15px;
  border-radius: 10px;
  margin-bottom: 30px;
  /* width: 250px; */
  height: 400px;
  margin: 10px;
}

.top_post_photo {
  object-fit: cover;
  width: 200px;
  height: 200px;
}

JSX

<div className="container">
    <div className="row text-center">
        <p className="top_hello">Hello Hiroko!</p>
        <div className="top_search col-12">
            <form className="top_search_input form-inline col-4" onSubmit={handleSubmit(getSearchResult)}>
            <input placeholder="Search Title or Maker" className='form-control' {...register('search', { required: true })} />
            <input className='btn btn-secondary' type="submit" value="Search" />
            </form>
        </div>
        <>
            {post.map((item,i) => (
              <div key={i} className="top_post col-6 col-lg-3">
                <div className="slideshow-container">
                  {item.photo &&
                  <div className="mySlides fade">
                    <img className="top_post_photo" src={item.photo} />
                  </div>
                  }
                  {item.photo2 &&
                  <div className="mySlides fade">
                    <img className="top_post_photo" src={item.photo2} />
                  </div>
                  }
                  {item.photo3 &&
                  <div className="mySlides fade">
                    <img className="top_post_photo" src={item.photo3} />
                  </div>
                  }
                  {item.photo4 &&
                  <div className="mySlides fade">
                    <img className="top_post_photo" src={item.photo4} />
                  </div>
                  }Ï
                  {item.photo5 &&
                  <div className="mySlides fade">
                    <img className="top_post_photo" src={item.photo5} />
                  </div>
                  }
                  <a className="prev" onclick="plusSlides(-1)">&#10094;</a>
                  <a className="next" onclick="plusSlides(1)">&#10095;</a>
                </div>
                <p>Title: {item.title}</p>
                <p>Condition: {item.condition_name}</p>
        
                <Link to={`/post/${item.id}`} className='btn btn-secondary'>Detail</Link>
              </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

Instructions for converting a MySQL select statement within a foreach() loop into an HTML form

I'm in the process of developing a course registration system for a small project. Currently, I have a table named 20182019carryovertbl from which I successfully select students who are carrying over their courses. Now, I need to transform this select ...

JQuery functions are functioning properly in Internet Explorer 10, but are encountering issues in Internet Explorer

My JavaScript function calls a jQuery function that works in IE10 but not in IE7. function test() { // Display message before calling jQuery function... alert("Before"); // Call the jQuery function... $("#boxscroll").getNiceScroll().resize(); // Display m ...

Could not locate module: Issue: Unable to resolve './Firebase'

I'm a beginner with React and I've been working on setting up Firebase in my React application. import firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/firestore'; var fire ...

Tips for setting unique click functions for each face of a cube using React Three Fiber

Hey there! I have created a basic Cube component using react three fibre. import {useState,useRef} from 'react'; import { useFrame } from '@react-three/fiber'; const Box = ({props}) =>{ const ref = useRef() const [hove ...

How to retrieve session information in a Next.js page utilizing withIronSession()

My attempts to access the session using req.session.get('user') have been unsuccessful even after reading the post titled Easy User Authentication with Next.js and checking out a related question on Stack Overflow about using next-iron-session in ...

What methods can I use to insert an array of objects into a Query?

I'm currently trying to understand how I can pass an array of objects into my GraphQL query. The documentation seems a bit confusing on this matter. In my project, I am using Apollo on the frontend, Graphql-yoga on the backend, and Prisma as my databa ...

Ways to retrieve the innerHTML of a Script Tag

After spending what feels like an eternity searching, I still can't figure out how to get the innerHTML of a script tag. Here's where I'm at... <script type="text/javascript" src="http://www.google.com" id="externalScript"></script ...

What is the best method for automatically closing the modal window?

I implemented a modal window on my website. Within the modal, there is a green button labeled "Visit" which triggers the "Bootstrap Tour". I aim for the modal to automatically close when the tour starts. To access this feature on my site, users need to ...

Combining CSS and JS files for accordion list - experiencing issues when used separately

Recently, I've been trying to create an accordion list and stumbled upon some code (HTML, CSS, and JS) on www.w3schools.com. When I have the code all in one document and run it as a single .html file, everything works perfectly. However, when I split ...

Step-by-step guide to launching a React SSR application on AWS Amplify without using Next.js

On May 18th, 2021, AWS introduced SSR support. You can learn more about it here. I had no trouble deploying a Next.js app, but I'm unsure how to deploy a custom React SSR app. There doesn't seem to be any documentation or blogs addressing this. ...

Select the even-numbered occurrences of a specific class in CSS using the nth-child()

I am encountering an issue with my table layout. The structure is similar to the following: <tbody> <tr class="row">...</tr> <tr class="row--expanded">...</tr> <tr class="row">...</ ...

z-index in CSS causes links to conflict

I am currently working on a project that requires an image to be displayed prominently on the website along with some links positioned behind it. However, I'm facing an issue where I can't click on the links after implementing z-indexes to layer ...

How can a React app be developed offline?

I am currently working offline with no access to the internet. Node.js is already installed on my system, but I encountered an error when trying to run the command npm create-react-app. Is there a way for me to execute npm commands and set up a react app ...

TurboRepo initiates the web server and promptly closes down without any issues

I have a turbo-repo set up using pnpm, and I am attempting to launch the React frontend for one of my clients with the following command: npx turbo run start --filter=testclient When executing this command, the output is as follows: • Packages in scope: ...

Position the Bootstrap Modal at the start of the designated DIV

When using a Bootstrap Modal to display larger versions of thumbnails in a photo gallery, there can be some challenges. The default behavior of Bootstrap is to position the modal at the top of the viewport, which may work fine in most cases. However, if th ...

Tips for sending several values using multiple select input

I am seeking advice on the best way to insert multiple values into a table using a multiple select input that includes more than one value. Would it be better to use a single value separated by "|", or to use data attributes like data-id, data-price, etc? ...

What is the proper way to utilize BrowserRouter when child routes are connected to components?

I recently started learning React and decided to create a signup form following a tutorial on React Tutorial. However, the tutorial turned out to be outdated. I attempted to implement browser redirects for the signup, login, and home page links by defining ...

The HTML element seems to be missing its height parameter

My element doesn't have a set height, but it's populated with images causing the Anchor around the images to be unclickable unless I assign a fixed height to .portfolio. Any ideas on how to resolve this? HTML Snippet : <h1 class="text-c ...

I am experiencing some layout problems with Joomla K2

Having some alignment issues in the header section of my article. I took a screenshot, but you can also check out the live page here. See the pic below: Upon inspecting the area I wanted to adjust, I discovered: span.itemAuthorDetailss position: relativ ...

Save data in MySQL and present a flexible number of rows in an HTML table

Let me illustrate the issue at hand with a hypothetical scenario involving numbers, although this may not be based on real data: In my system, up to 2 teachers grade a student on their performance of tasks. Let's say the student has to complete 10 ta ...