The secret to perfectly align a container in react-bootstrap

I am currently working on a website using react-bootstrap, and I have come across an issue where I need to change the width of a container to 60% while still keeping it centered. Despite adjusting the width, I am having trouble centering the container. Can anyone provide guidance on how I can achieve this?

Below is the code snippet:

import {Row, Col, Container, Button} from "react-bootstrap"
import '../CSS/Room.css'

const Room = () => {
    return (
        <>
            <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>
        </>
    )
}

export default Room

Below is the CSS code snippet:

.roomfac {
    display: flex;
    widtH: 60%;
    margin: auto;
}

Answer №1

Here is a CSS snippet you can use to center your container on the page.

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

Answer №2

Give this a shot:

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

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 distinguishes CSS properties for Id versus class selectors

Currently in the process of creating my inaugural website, which consists of just four pages. Each page follows the standard layout structure with a header, navigation bar, content division (div id="content"), and footer. As I delve into adding CSS proper ...

Are you facing issues with Handlebars parsing?

I am struggling to identify the issue in my HTML/JS code. Here is my HTML/JS: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script src="handlebars-v1.1.2.js"> ...

Employ the find() function to ascertain the result of a condition

I'm struggling to grasp how to utilize the find() method in a conditional statement. In simple terms, I want the conditional to evaluate as true if the value of item.label is equal to the value of e.target.value. if (this.props.Items.find(item => ...

Having Troubles with PHP File Upload Form

Executing index.php initiates the user input of metadata and files: <!DOCTYPE html> <html lang="en> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"/> <meta http-equiv="X-UA-Compati ...

SimpleLightBox refuses to function

Having trouble getting SimpleLightBox to work properly? It seems like when you click on an image, it opens as a regular image on a blank page. I've added the JS and CSS files correctly (I double-checked in the source code) and included the HTML and JS ...

Struggling with main content not properly overlapping with nav bar in HTML and CSS code

Looking for assistance with centering the main content area on a webpage both vertically and horizontally. After adding a CSS nav bar, scroll bars appeared on the page and the main div lost its center positioning, seeming to be shifted down and to the rig ...

Avoid having the toast notification display multiple times

I've been working on implementing a toast notification for service worker updates in my project. However, I'm facing an issue where the toast notification pops up twice. It seems to be related to the useEffect hook, but I'm struggling to fig ...

What is the best way to iterate through multiple iframes?

I need help figuring out how to load one iframe while having the next one in line to be displayed. Is there a way to create a script that cycles through multiple iframes after a certain amount of time? ...

Changing text color with JQuery animation

Is there a way to animate text color using jQuery/jQuery UI? I want the text color to change from #000 to #F00 when an event is triggered, then fade back to #000 over 3 seconds. I attempted using effect("highlight", {}, 3000) with the highlight effect, bu ...

Utilize Flexbox to create a layout with 3 divs, organized into two columns where one column

I am attempting to transform <div></div> <div></div> <div></div> Three consecutive divs into the following format. Div 1 is red, div 2 is green, and div 3 is blue. I have achieved this using floats, like so: .div1 { ...

Troubleshooting problems with a JavaScript game that involves guessing numbers

I have been given a challenging Javascript assignment that involves using loops to create a counting betting game. The concept is simple: the User inputs a number, and the computer randomly selects a number between 1 and 10. The User can then bet up to 10 ...

Javascript/jQuery for enlarging and shrinking a div

Struggling with a function I'm implementing for a website. My goal is to move and expand a div upon button click, with the text on the button changing to "close". When the close button is clicked, the div should return to its original position. I&apo ...

Dynamic extension of classes in SCSSORExtending classes

When working with Vue, I encountered a situation similar to :style="{ [`--chip-bg-hover`]: hoverColorValue, [`--chip-bg-active`]: activeColor, [`--chip-border-hover`]: borderHoverColorValue, }" Then, i ...

Contrasting Approaches to Defining Components in ReactJs

There are two different approaches to declaring components in ReactJs that I've come across. Despite both options working well, they have their own unique characteristics. Option 1: function David(props){ return <h1>Hey there! {props.name}, ...

Issues with Image and Product Name Rendering in Outlook for Windows

Having a bit of trouble with Outlook PC not cooperating with my product images and names. While other email clients show the product names below the images as intended, Outlook PC is causing the names to appear next to the images like this - Product name ...

Enhancing speed and efficiency when zooming in on various elements using React

Issue: The zoom functionality in my React application becomes sluggish when I have over 20 components rendered. The app needs to handle zooming with thousands of components being rendered. Current zoom implementation: Currently, in my application, there ...

Error in Next.js when the value of the target does not change in React-Select's

I am brand new to the world of react/nextjs and I keep encountering a frustrating error that says "Cannot read properties of undefined (reading 'value')". Despite trying various approaches, including treating select as a simple HTML tag, I have s ...

What is the process for adding a personalized button tag within rows using material-table and TypeScript, and what specific properties does it anticipate receiving?

Hey, I have a few questions that I could use some help with :) I'm trying to add both an Avatar tag and an Edit Button to every row in my table, but the Edit Button appears on both. How can I move the action to the right side of the table? Also, how d ...

Styling the file input type in AngularLearn how to customize the

I've come across numerous queries on how to style an input type file, but I'm struggling to implement it in an angular context. So, what is the best way to customize the appearance of an input type file within an angular application? Below is t ...

CSS: selecting the adjacent siblings of a certain class, starting from the first and

I am working on achieving the following goal: https://i.sstatic.net/xHoIG.png Elements containing values should have a gray 'ribbon'. Elements with values are given a class selected, while elements without any value do not have this class. Thi ...