The CSS code seems to be ineffective when attempting to center elements with a specific width in react.js

Hey everyone, I'm currently working on developing a web application using react-bootstrap and I've encountered an issue with adjusting the width of my row and centering it. I have already created the necessary CSS and JS files, but I am unable to successfully center the row. Interestingly, when I transferred my code to codesandbox, everything worked perfectly fine. Does anyone have any insights into why this might be happening?

Here is my code snippet:

<Container fluid>
    <Row className="roomfac fontReg">
        <Col lg={3} className="text-center">
            <img src="./Images/logofridge.png" alt="Logo 1"/>
            <h3 className="fontSB">Fridge</h3>
        </Col>

        <Col lg={3} className="text-center">
            <img src="./Images/logoAC.png" alt="Logo 2"/>
            <h3 className="fontSB">AC</h3>
        </Col>

        <Col lg={3} className="text-center">
            <img src="./Images/logowifi2.png" alt="Logo 3"/>
           <h3 className="fontSB">Wifi</h3>
        </Col>

        <Col lg={3} className="text-center">
            <img src="./Images/logotv.png" alt="Logo 4"/>
            <h3 className="fontSB">TV</h3>
        </Col>
    </Row>
</Container>

This is how I have styled my elements in CSS:

.roomfac {
    display: flex;
    width: 60%;
    justify-content: center;
    margin: auto;
}

Answer №1

Confirmed to be functional on both Chrome and Edge. Double check the correct inclusion of your CSS files or consider utilizing inline CSS within JSX.

<Row style={{display:"flex",width: "60%",margin: "auto",justifyContent: "center"}} className="fontReg">

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

What is the best way to incorporate this HTML and script into a React component?

After receiving the embedded HTML and script from a platform, I discovered that a button triggers the script. It was originally designed to be embedded on a website, but I am attempting to integrate it into a React application. Here is the code provided fo ...

Image superimposed with vertical dimension

I have a photo with specific dimensions and I want to create a div box with a button inside the image, similar to what is shown in this example: Example Image Here is my current code attempt: .wrapper { width: auto; text-align: center; } .wrapper: ...

Setting up Electron with React and TypeScript: A Comprehensive Guide

I've been developing an app using Electron, React (jsx), and Babel. However, I recently made the switch to TypeScript and I'm struggling to get everything functioning properly. The npm packages I've tried only work for either React or TypeSc ...

Dilemma: Navigating the Conflict Between Context API and Next.js Routing in React

Recently, I was following a Material UI tutorial on Udemy and decided to set up a Context API in Create React App without passing down props as shown in the tutorial. Later on, when I tried migrating to Next JS with the same Context API, I started encounte ...

utilizing the active class with react js

Apologies for the question, but I am facing an issue where adding an active class to a button is affecting all buttons when clicked. How can this be fixed? Here is the code snippet: <div className=""> {category.items.length === 0 ? ( ...

Tips for implementing multiple middlewares in Next.js using the middleware.ts script

In the development of my Next.js project, I am exploring the implementation of multiple middleware without depending on external packages. Although I have seen examples of using a single middleware in Next.js with the next-connect package, I aim to achieve ...

Equal height elements - Bootstrap

Is there a way to make all elements in a list the same height, even if one element has more text than the others? I've been using divs for this purpose, but I'm open to switching to li items. Any advice on the best approach? I'm currently w ...

I am curious to learn more about React (version 16.13.1) that I've implemented using the create-react-app tool

I recently received a catalog for my new program, but I'm struggling to comprehend the contents of these documents. ...

Exploring the power of searching JSON data using ReactJS

After reading through the "Thinking in React" blog, I'm inspired to create something similar. Instead of filtering an array table, I want it to display the row that matches the input value. I have attempted this and created a jsfiddle example here: j ...

The table's pagination displays above, thanks to Tailwindcss

I'm facing an issue where the pagination is showing up above the table, but I was expecting it to be displayed after the table. It would be ideal if the pagination appeared right after the table when adding multiple rows. Check this link for more inf ...

Incorporating React-router into your Jekyll website

Recently, the idea of creating a Jekyll SPA blog crossed my mind. I was considering incorporating React.js / React Router or Vue.js / Vue Router to achieve that seamless SPA routing experience. Can this be accomplished, and if so, where exactly should I i ...

Using JQuery to Customize Navigation Menu Targeting

On my website, I am trying to make an href button and a menu fade in as the page loads. However, I am struggling to find the correct code due to its placement within multiple tags, especially since I am new to JS and JQuery. I have provided a fiddle with a ...

Is it possible to slide-toggle and alter the background color of a div when clicked?

Imagine having several div's on a webpage all with the ID of "Toggle". Each div contains two other smaller divs. "Headline" which is always visible. "Comment" which appears/disappears when the headline is clicked (initially hidden). How could I ac ...

Customize the appearance of tables using MUI typography overrides

Do you have a website that can import markdown or mdx files and render them? Are you currently using the normal markdown tables formatted with table: (props) => <Typography variant="table">{props.children}</Typography>? If so, thi ...

links to css and javascript

I am having trouble with what should be a simple task! On my webpage, I have this link: <a class='action' href='javascript:void(0)' OnClick='run()'> run </a> Along with the following CSS: .action { color: # ...

Using Conditional Rendering and ReactCSSTransitionGroup for Dynamic Animations

I have developed a small application that displays different components based on a Redux state. I am trying to add a "fade" animation when one of the components renders, but unfortunately, it is not working as expected. Here is my current setup: content.j ...

Building a Gatsby website with a PHP contact form

Currently, I am developing a Gatsby portfolio and my goal is to integrate a PHP contact form. While exploring various examples online, many of them suggest using external resources to handle email sending directly from the website itself. One such recommen ...

Showcasing all elements of an xml through jquery while implementing a filter

Trying to implement a filter on XML using jQuery. The filtered results are showing based on the condition, but facing difficulty in displaying all XML items when the flag is set to 0; meaning that when the flag is zero, all XML items should be displayed ...

Styling the jQuery location picker input with background and focus effects

While working on a web app using jQuery locationpicker, I noticed that it's causing some styling issues with the input. Despite being able to adjust properties like width, padding, and border, changing the background requires using jQuery. Here is th ...

React-select allows for multiple selections within a component when the onChange function

I am currently utilizing react-select. Per the official documentation, it recommends using 'isMulti' to select more than one option. Below is the custom component that I have created. import React from 'react'; import { Form } from &ap ...