Alignment of React page gets messed up upon inclusion of Gallery component

I have searched for solutions online, but nothing seems to work for me. I am facing an issue with my webpage that has multiple sections, and I want to display them one after the other vertically.

Here is the code snippet:


import React from 'react';
import './Profile.css';

import UserProfile from '../assets/fake/studentinfo'
import TextContents from '../assets/translations/TextContents';
import Gallery from 'react-grid-gallery';
import DetailReview from '../components/materialdesign/DetailReview';


class Profiles extends React.Component{

    render(){
        const IMAGES =
        [{
                src: "https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg",
                thumbnail: "https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_n.jpg",
                thumbnailWidth: 156,
                thumbnailHeight: 156
        },
        {
                src: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_b.jpg",
                thumbnail: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_n.jpg",
                thumbnailWidth: 156,
                thumbnailHeight: 156
        },
        
        {
                src: "https://c4.staticflickr.com/9/8887/28897124891_98c4fdd82b_b.jpg",
                thumbnail: "https://c4.staticflickr.com/9/8887/28897124891_98c4fdd82b_n.jpg",
                thumbnailWidth: 156,
                thumbnailHeight: 156
        },
        {
            src: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_b.jpg",
            thumbnail: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_n.jpg",
            thumbnailWidth: 156,
            thumbnailHeight: 156
        }]
        
        // The remaining JSX code has been modified 
        
    }   
}

export default Profiles;

and here's the relevant CSS:


.profile-container {
        margin-top: 3rem;
        margin-bottom:5rem;

}

...

However, despite this setup, the layout appears different than expected:

https://i.sstatic.net/WTPuY.jpg

The text "let's put the tabs layout", Reviews,... should ideally be positioned below the image gallery. Any insights on why this might not be happening?

Answer №1

https://i.sstatic.net/f4q4i.gifThe root cause of the problem lies in the default CSS utilized by the Gallery Component within the 'react-grid-gallery' library.

To rectify this issue, insert the following CSS code into your stylesheet:

#ReactGridGallery{
  display:flex;
}

Implementing this adjustment should effectively resolve the issue.

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

Blending HTML elements with ASP.NET code

Trying to concatenate two strings separated by a line break. This snippet shows what I am attempting: <td>@(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td> <td>@(string.Join("<br /& ...

Exceeded maximum file size event in Dropzone

I am currently implementing dropzone in my form to allow users to upload images. In the event that a user selects a file that exceeds the configured limit, I want to display an alert message and remove the file. Below is my current configuration: Dropzone ...

Add a 'tag a' directly following 'img'

Check out this code snippet: <a href="#" class="list-group-item"> <span class="badge"><?=$st ?></span> <img class="small_profile_pic" src="<?=$pic ?>" /> aaa<a ...

Refreshing the dropdown selection to a specific option using AngularJS and either JavaScript or jQuery

Currently, I am facing an issue with resetting the select tag to its first option. I have implemented Materialize CSS for styling purposes. Despite my efforts, the code snippet below is not achieving the desired outcome. Here is the JavaScript within an ...

Slick Slider fails to load on web browsers

Hi everyone, I have a snippet of HTML code that I need help with: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/1.6.0/slick.css"/> </head> <body> ...

utilizing the power of Ajax in Laravel version 5.7

I am seeking assistance in utilizing AJAX to delete and update table rows with a modal in Laravel 5.7. I am new to AJAX and would appreciate any help, especially in explaining how AJAX sends/gets data in the controller and if there are any differences betw ...

Make TextField automatically select all text when focused

Is there a way to make a TextField in Material-UI select the entire text when clicking, tapping, or focusing on it? I have successfully implemented this functionality with an onFocus handler using event.target.select() in other React apps, but for some rea ...

Is there a way to insert rows and columns into the table headers using React Material UI?

I am new to working with material UI and I am having trouble figuring out how to add columns in the table header. The image below shows what I am trying to achieve - under "Economics", there should be 3 columns, each of which will then have two more column ...

Aligning the Navigation Bar to the Upper Right Corner

I'm attempting to rearrange my Nav Bar to be at the Top Right, with my logo on the Top Left all in one line. Unfortunately, I'm struggling to achieve this and could really use some guidance. As a newcomer to HTML and CSS, I find it challenging to ...

Encountered an issue when attempting to run the React js app using npm start

npm ERROR! CODE ENOENT npm ERROR! SYSCALL OPEN npm ERROR! PATH C:\Users\Ahsan Raza\Desktop\myapp\package.json npm ERROR! ERRNO -4058 npm ERROR! ENOENT: could not find file or directory, open 'C:\Users\Ahsan Raza&bsol ...

The SSR React application rendering process and asynchronous code execution

When using SSR with React, how is the content that will be sent to the client constructed? Is there a waiting period for async actions to finish? Does it wait for the state of all components in the tree to stabilize in some way? Will it pause for async ...

Can I determine if onSnapshot() has detected any updates prior to fetching the data?

While navigating to a page, I pass parameters like "Discounts" and display that number in the render(). However, I call onSnapshot() right at the beginning of navigating to that class. My goal is to initially display only the value of the parameter and the ...

What is the best approach to repurpose a component when small adjustments are needed?

Can a customized slider component be created in React that can be reused with slight variations? For example, having the second one include a 13% field. View image description here ...

What is preventing the element from being positioned at the bottom of the container?

I have a vertical bar chart with 5 different colored sub-containers. I'm trying to position the 'chicken' sub-container at the bottom of the bar without any bottom-margin, but so far my attempts have been unsuccessful. When I try using absol ...

Guide on fetching data from a different php file using jQuery's .load() method?

I am trying to use a basic .load() function from jQuery to load a div element with an id from another file in the same directory when changing the selected option in a selector. However, I am having trouble getting it to work. Nothing happens when I change ...

Accessing the variable's value within a separate if statement within the function

I have a function that retrieves data from JSON and passes it to render, but I had to include two different conditions to process the data. Below is the function: filterItems = () => { let result = []; const { searchInput } = this.state; c ...

Alert message in jQuery validation for the chosen option value

I am attempting to validate a combo box with the code provided below. Currently, I receive multiple alert messages even if one condition is true. My goal is to only display one alert message when a condition is met and highlight the other values in red. Th ...

Creating a React table with customizable columns and rows using JSON data sources

My query is this: What is the most effective way to dynamically display header names along with their respective rows? Currently, I am employing a basic react table for this purpose. As indicated in the table (2017-8, 2017-9, ....), I have manually entere ...

Markdown Custom Parsing

Every week, I create a digest email for my university in a specific format. Currently, I have to manually construct these emails using a cumbersome HTML template. I am considering utilizing Markdown to automate this process by parsing a file that contains ...

CSS Grid: Dividing items equally based on the number of items present

Currently, I am delving into grid layouts in CSS and experimenting with code to divide a row. Here is the snippet I am playing around with: .grid-sample { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; row-gap: 4rem; padding: 0 5rem ...