What are the steps to vertically aligning rows in bootstrap?

I've been exploring different solutions to vertically center my rows within the container. Adding d-flex and align-items-center did work for centering them vertically but caused the rows to appear side by side. I'm curious if there's an alternative method for achieving vertical centering or if there's a clever workaround that can be applied.

import React from "react";

function Projects() {
return (
    <div className="home">
        <div className="container central align-items-center">
            <div className="row justify-content-center my-auto">
                <div className="col-3">
                    <img
                        src="/assets/motherboard.jpg"
                        className="img-fluid"
                        alt="Green motherboard"
                    />
                </div>
                <div class="col-5">
                    <h1 class="font-weight-light">Home</h1>
                    <p>
                        Lorem Ipsum is simply dummy text of the printing and

                    </p>
                </div>
            </div>
            <div className="row justify-content-center my-auto">
                <div className="col-3">
                    <img
                        src="/assets/motherboard.jpg"
                        className="img-fluid"
                        alt="Green motherboard"
                    />
                </div>
                <div className="col-5">
                    <h1 className="font-weight-light">Home</h1>
                    <p>
                        Lorem Ipsum is simply dummy text of the printing and

                    </p>
                </div>
            </div>
            <div className="row justify-content-center">
                <div className="col-3">
                    <img
                        src="/assets/motherboard.jpg"
                        className="img-fluid"
                        alt="Green motherboard"
                    />
                </div>
                <div className="col-5">
                    <h1 className="font-weight-light">Home</h1>
                    <p>
                        Lorem Ipsum is simply dummy text of the printing and

                    </p>
                </div>
            </div>

        </div>
    </div>
);
}

export default Projects;

The css I'm using is here:

@import url('https://fonts.googleapis.com/css?family=Lobster&display=swap');
@import url('https://fonts.googleapis.com/css?family=Assistant&display=swap');

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
  sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
  monospace;
}
.central {
  height: 87.5vh;
}

h1 {
  font-family: 'Assistant', Arial, serif;
  font-size: xxx-large;

}

.home {
  background-image: url("../public/assets/computer.jpg");
  background-size: cover;
}

JSFiddle: https://jsfiddle.net/mqud7134/

Answer №1

From my interpretation of the preface, it seems like you need to align each div vertically in a column.

To achieve this, you can apply the following CSS style to the container class:

import React from "react";

function Projects() {
return (
    <div className="home">
        <div className="container central align-items-center" 
           style={{ display:"flex", flexDirection:"column", flexWrap:"nowrap", justifyContent:"center",     
                      alignItems:"center"}}>

        .  
        . 
        . 
        </div>
    </div>
);
}

export default Projects;

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

Insert item at the end of the box and move all elements upwards

Hello! I'm experimenting with creating something using javascript's createElement method. My goal is to achieve an effect similar to this image: https://i.stack.imgur.com/itKUK.gif Currently, my code is functional, but the animation goes from to ...

Using React.js to set the value of a TextField component directly from the state variable

I have a service that makes an axios request to fetch transaction details: getTransaction(batchRef) { return axios.post(`${API_BASE_URL_GET_OUTWARD_TRANSACTION}`, { batchRef: batchRef, }); } This service is called like this: const [viewOut ...

Having trouble with React-leaflet map rendering correctly within the Ionic framework

https://i.sstatic.net/wXM7b.png I have encountered numerous individuals facing this issue, but none of the suggested solutions have resolved it for me. I am confident that I have set up everything correctly. This is my index.html: <!DOCTYPE html> & ...

Every time an action is carried out in the app, React generates countless TypeError messages

Whenever I'm using the application (particularly when started with npm start), my console gets flooded with thousands of TypeError messages like this: https://i.sstatic.net/3YZpV.png This issue doesn't occur when I build the app... It's fr ...

Canvas with a button placed on top

I am working with a canvas and trying to position an HTML element over it using CSS. My goal is for the button to remain in place on the canvas even when resizing the entire page. Here is the code I am currently using. https://jsfiddle.net/z4fhrhLc/ #but ...

Common issue with setting up createContext and using useContext in Next Js

Hey there! I'm a beginner with Next.js and I've run into an error that I can't seem to figure out. I'm not sure what's causing it or how to troubleshoot it. Here are some screenshots and code snippets: https://i.sstatic.net/6MVWgRB ...

When implementing the `map` method in Next.JS Static Generation, SEO performance may not be optimized

Currently utilizing Next.JS for building a static website with the primary focus on creating a highly SEO-optimized site. The deployment on Vercel is successful, but I have observed that some content is not directly present in the HTML files. For example, ...

CSS Styling Dropdown Menu for Internet Explorer 5 and Internet Explorer 11

I am encountering an issue with a select box that is coded as follows: <html:select property="list_data" size="12" style="width: 350px;" ondblclick="JavaScript:doOK()"> <html:optionsCollection property="list_data" label="codeAndNameLabel" val ...

You are unable to update the state while using fetch, even with the arrow function

As a newcomer to react, I recently delved into using the fetch API to retrieve population data from an external source. Despite successfully pulling the data, I encountered an issue where updating the state within the fetch block did not result in the ch ...

Issue in Chrome when using CSS clip property on nested div elements

Take a look at this fiddle Here is the HTML structure: <div class="parent"> <div class="child"></div> </div> This is the corresponding CSS code: .parent { position: absolute; width: 100px; height: 100px; background: re ...

What is the process for obtaining Style.css, additional CSS, and JavaScript files from a live single page website?

I am currently facing a challenge with a live single page website where I need to make some fixes. Unfortunately, I am unable to access the Style.css file, along with other css and javascript files. Although I managed to save the html file by using Ctrl+s, ...

What is the best way to ensure input text fills the entire grid?

Take a look at this code snippet: <div class="form-group col-md-6"> <label class="col-md-4">Last Updated (Real Time)</label> <input class="form-control col-md-8" type="text" ng-model="status.lastUpdated" ng-readonly="true"/ ...

The Next.js application refreshes when navigating to a new page

Currently, I am working with nextjs version 12.1.6, react-dom version 18.0.5, and next-auth 4.6.1 in my application. It consists of two routes - an index page and a login page. However, whenever I navigate between these two pages, the entire app rerenders. ...

Tips for incorporating filtering and sorting functionality in a API-focused application using React and Next.js

In my current project, I am developing a React application using Next.js. The main goal is to fetch data from an API and display cards based on user-selected filters. Specifically, I aim to retrieve the cards initially and then filter them according to the ...

Using CSS to target specific attributes on standalone elements

Ever since I stumbled upon AMCSS, I have been utilizing standalone attribute selectors. Recently, I made the switch from Compass to cssnext, only to discover that syntax highlighting appears to be malfunctioning in Atom and other platforms where I tested i ...

What could be causing this jQuery color picker to malfunction when used inside a Bootstrap modal?

Currently, I am utilizing the fantastic jQuery color picker provided by Although it functions as expected in "normal" scenarios, I have encountered an issue where the picker fails to display when the input parent element is nested within a Bootstrap 3 mod ...

How can I overlay text on top of an image?

I want to create a design where half of the text overflows and overlays the image on the right side. How can I achieve this using a Grid item? I've tried using "absolute", "relative", and "z-index" positions, but they don't seem to work in the MU ...

Guide on how to combine the strings retrieved from an API

I'm having trouble concatenating multiple sentences together and highlighting specific words in each sentence. Although I can successfully highlight one sentence using the code below, I haven't been able to concatenate more than one sentence: th ...

React Error: Invalid Element Type with Named Exports

I've been diving into the world of React hooks and functions, working on three different files. First, there's one that establishes a context called SummaryContext. The second file contains a class component that consumes this context named WikiS ...

Experience the enhanced features of Joomla 4 with a unique horizontal menu spanning across 2 rows

Currently, I am working with Joomla 4 using a customized Cassiopeia theme as the child theme. My goal is to display the menu items across two horizontal rows instead of one. However, whenever I add an item to the menu, it causes the navigation container to ...