Implementing Grid column reversal in React with the help of Styled components

I am trying to reverse the order of these components. I have tried using standard display: grid; and Google suggested grid-auto-flow: dense;, but it didn't work as expected. Could the issue be with the structure of the components? Ideally, I would like every even component to be displayed in reverse order.

In index.js

            <ContainerCard>
              <CardImg src={photo1}/>
              <CardInfo>
                <CardH2>Title #1</CardH2>
                <CardP>
                     Some text 
                </CardP>
              </CardInfo>
            </ContainerCard>

In Styled.js

export const ContainerCard = styled.div`
  display: grid;
  grid-template-columns: 1fr 1fr;
    grid-auto-flow: dense;

    @media screen and (max-width: 768px) {
        grid-template-columns: 1fr;
    }
  
`

Check out my local host here

Answer №2

After encountering this recurring problem multiple times, I finally found a solution to reverse the order by flipping both the grid and its elements.

transform: scale(-1, 1);

Check out the code snippet on Codepen here: https://codepen.io/SarahCoder/pen/BYVeRPk

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

Are website files safe to store in the public_html directory?

Previously, I had a backend built in Laravel and a frontend in React. Recently, someone converted my frontend to Next.js. I noticed that he placed both the frontend and backend in the public folder. Prior to this conversion, I had the website app in a fol ...

Is it impossible to use CSS for absolute positioning of text?

I am currently learning CSS and HTML, as I'm working on a project for my final school assignment. My goal is to position the text "Welcome" absolutely within a specific div that I've created. However, despite multiple attempts, I can't seem ...

Utilizing State and Props in React for Radio Buttons

After following the guidance provided in this particular Stack Overflow response: Trying to Reset a group of Radio button in REACT through a button Unfortunately, I have been unsuccessful in getting it to function correctly. My current project involves c ...

The Mui DataGrid React has surpassed the maximum call stack limit

One of the DataGrid tables in my project seems to be causing issues, and I can't seem to pinpoint the problem. To provide a clearer understanding, I have prepared a codesandbox demonstration showcasing the issue. Any assistance or insights would be g ...

Tips on updating arrow button icon when clicked using jquery

I am currently working on a project where I have a button icon that I want to change upon clicking it. I am using the following jQuery code: <script> $('div[id^="module-tab-"]').click(function(){ $(this).next('.hi').sl ...

Reactjs implemented with Material UI and redux form framework, featuring a password toggle functionality without relying on hooks

Currently, I am working on a react project where I have developed a form framework that wraps Material-UI around Redux Form. If you want to check out the sandbox for this project, you can find it here: https://codesandbox.io/s/romantic-pasteur-nmw92 For ...

React TypeScript - creating a component with a defined interface and extra properties

I'm completely new to Typescript and I am having trouble with rendering a component and passing in an onClick function. How can I properly pass in an onClick function to the CarItem? It seems like it's treating onMenuClick as a property of ICar, ...

Having issues with navigating back to the previous route in React?

After using useNavigate(-1) or window.history.back(), I encountered the following error. This was not an issue before. "A POP navigation is being blocked to a location that wasn't created by @remix-run/router. Although the block will fail silent ...

Handling multiple patch requests using React and Redux when onBlur event occurs

Currently, I am using Redux-form for editing guest information. Whenever a field is left, the content of that field gets patched to the guest through a simple patch request and the store is updated accordingly. However, an issue arises when I use Google fo ...

The render process encountered an error with the imported function test in React Mocha/Enzyme

For testing purposes, I am checking if my component renders correctly. Below is the test that I have written: describe('Send Action', () => { it ('Should render without errors', () => { const props = { action: Map({po ...

Using Arrays in Combination with React

After creating a list, I found myself in unfamiliar territory: let myList = [ { id: 'budget', label: 'Budget', widget: <Budget />, checked: true }, { id: 'lastEmployees', l ...

What is the best way to arrange the elements vertically within a flex container?

In my current code snippet, I have the following setup: <section class="body1"> <h1 class="text1">Tours around the world</h1> <h3 class="text1">Great experiences</h3> <form action="/respuestaUsuario/"> ...

Unable to identify the Xpath selector for the "Account settings button" and "find my iPhone" features within iCloud

When trying to access my iCloud account settings and locate the "Find my iPhone" button on iCloud.com, I am encountering issues with my selectors. It seems like there are no frames on the page, but the Xpaths I'm using are not matching. Here are the ...

Struggling to combine select dropdown choices in one calculation

​​I'm currently working on a project where I need to create a website that multiplies three numbers selected from dropdown menus together. However, when I attempt to perform the calculation, I only get the result "1" displayed. I've spent sev ...

The div is not displaying the background image as intended

.cover-image { margin-bottom: 0px; height: 350px; color: white; text-shadow: black 0.3em 0.3em 0.3em; } <div class="cover-image" style="background: url('~/images/hdpic.jpg') no-repeat; background-size:cover"> </div> I&apo ...

What might be causing my background image not to appear?

I seem to be having trouble with the background image not displaying on my screen. I am confident that the URL is accurate, as I have successfully used it in other instances. Here is a snippet from my CSS file: body{ background : url(assets/image/mai ...

Incorporating a scrollbar when a div exceeds the bottom of the viewport

I am encountering an issue on my webpage with a <div> that contains a <table> with rows of varying heights: <html> <head></head> <body> <div> <table> <tr>... <tr>... ... </ ...

I am experiencing issues with my drag and drop feature not functioning properly

I am looking to reposition my #timebase1 div within the draghere div. Currently, it only moves the start of the div, but I would like to be able to drop it anywhere inside the draghere div. function handleDrag(e) { var id = e.id; ...

Responsive horizontal tab bar using bootstrap and blazor for a seamless user experience

For my blazor tab control, I need the horizontal tab bar to be responsive when there are numerous tabs. Despite using tc-tabs, the scrollbar does not appear and it forces additional tabs to display on a new line. https://i.sstatic.net/QTrn7.png I am inte ...

Tips for handling transparent areas during a hover event

Is there a way to make only the rhombus image respond to hover events? I want to exclude the transparent area, as shown in this picture. <img src='http://s30.postimg.org/xpd6gwla9/1_Copy.jpg' id="first"> #first:hover { -moz-box-shadow ...