I found myself pondering the method to achieve the slightly blue tinted box that sits behind the image

Can you assist me in achieving this specific look? I have my MUI app bar and home page set up, but I'm unsure how to create the blue-ish box behind the image. Should I place the container within my app bar or integrate it into my homepage file? Additionally, there's a significant gap between the app bar and title in my current design that I would like to eliminate.

Desired outcome: https://i.stack.imgur.com/18glc.png

Current result: https://i.stack.imgur.com/BxG9x.png



Here is a snippet of the code:

return (
    <ThemeProvider theme={theme}>
        <Grid container component="main" sx={{ backgroundColor: '#FBF3EA', display: "flex", justifyContent: "center", position: 'absolute' }} >
            <Box component="section">
                <Container sx={{ py: 10 }} maxWidth="lg">
                    <Grid container alignItems="center" spacing={3}>
                        <Grid item xs={12} md={5}>
                            <Box sx={{
                                display: 'flex',
                                ml: '850px',
                                width: '500px',
                                mt: '-160px'
                            }}>
                                <Container sx={{backgroundColor: '#99CCCB', width: 300, height: 500 }} xs={12} sm={6} md={6}></Container >
                            </Box>
                            <Typography component="h1" variant="h3">
                                Real Pet food fresh from the fridge.
                            </Typography>
                            <Stack direction="row" spacing={2} sx={{ mt: 4 }}>
                                <Button size="large" variant="contained" sx={{
                                    backgroundColor: '#124944',
                                    textTransform: 'none'
                                }}>
                                    Shop Now
                                </Button>
                            </Stack>
                        </Grid>
                        <Grid item>
                            <Grid container sx={{display: 'flex', flexWrap: 'nowrap'}}>
                                <Grid item>
                                    <img width="150px" height="175px" src={dogHome} alt="dog food" />
                                </Grid>
                                <Grid item sx={{width:'100%'}}>
                                    <Card>
                                        <CardContent>
                                            <Grid container spacing={3}
                                                  sx={{
                                                      "& .MuiGrid-item:last-child > .MuiBox-root": {
                                                          border: "none",
                                                      },
                                                  }}>
                                                <Grid item>
                                                    <Box >
                                                        <Typography fontFamily="Righteous" gutterBottom color="text.secondary" variant="h4" sx={{display: 'flex', justifyContent: 'center'}}> 200 + </Typography>
                                                        <Typography fontFamily="Righteous" variant="h5" sx={{display: 'flex', justifyContent: 'center'}}> Nutritional Complete </Typography>
                                                    </Box>
                                                </Grid>
                                                <Grid item>
                                                    <Box>
                                                        <Typography fontFamily="Righteous" gutterBottom color="text.secondary" variant="h4" sx={{display: 'flex', justifyContent: 'center'}}> 1k </Typography>
                                                        <Typography fontFamily="Righteous" variant="h5" sx={{display: 'flex', justifyContent: 'center'}}> Product Sales </Typography>
                                               </Box>
                                                </Grid>
                                                <Grid item>
                                                    <Box>
                                                        <Typography fontFamily="Righteous" gutterBottom color="text.secondary" variant="h4" sx={{display: 'flex', justifyContent: 'center'}}> 96% </Typography>
                                                            <Typography fontFamily="Righteous" variant="h5" sx={{display: 'flex', justifyContent: 'center'}}> Client Satisfaction </Typography>
                                                    </Box>
                                                </Grid>
                                            </Grid>
                                        </CardContent>
                                    </Card>
                                </Grid>
                            </Grid>
                        </Grid>

Answer №1

To achieve the desired positioning, apply position: absolute and z-index: -1 to your Box component:

<Box sx={{
    display: 'flex',
    position: 'absolute',
    top: '0px',
    right: '200px', // make adjustments here
    width: '500px',
    zIndex: '-1'
}}>

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

Problems with Bootstrap affix scrolling in Internet Explorer and Firefox

I'm encountering an issue with the sidebar on my website. I've implemented Bootstrap affix to keep it fixed until the end of the page, where it should move up along with the rest of the content at a specific point... Everything seems to be worki ...

Trigger file upload window to open upon clicking a div using jQuery

I utilize (CSS 2.1 and jQuery) to customize file inputs. Everything is working well up until now. Check out this example: File Input Demo If you are using Firefox, everything is functioning properly. However, with Chrome, there seems to be an issue se ...

Collaborative React front end elements are now housed in their own TypeScript project within Visual Studio 2017

In Visual Studio, our project structure includes the following: PublicClient, Admin, and SharedComponents. The SharedComponents project is essential because many components are shared between our client and admin interface. This structure is based on the f ...

What is the best way to change the height of cells within a grid layout?

Enhancing the buttons with a touch of depth using box-shadow resulted in an unexpected outcome - the shadows bleeding through the gaps and causing uneven spacing. https://i.sstatic.net/LYssE.png In an attempt to rectify this issue, I decided to tweak the ...

Is it possible to pass makeStyles as a prop in React components?

Within my component, I am using a prop named styling to apply inline styles. However, I would like to pass some predefined styles that I have written using the makeStyles function. The specific style I want to pass is detailed below: const useStyles = ma ...

Give properties to a function that is being spread inside an object

While working with React, I am facing a challenge of passing props from the instanced component into the mockFn function. The code example below is extracted and incorporates Material UI, but I am struggling on how to structure it in order to have access t ...

How can you change the list-style-type to switch between lower-alpha and decimal on nested items within an ordered list?

I am attempting to reverse the list-style-type of nested items within an ordered list, including sub-items and sub-sub-items. I have tried using CSS counters but it doesn't seem to be working. Can anyone point out what I might be doing incorrectly? ol ...

Using Angular material to display a list of items inside a <mat-cell> element for searching

Can I use *ngFor inside a <mat-cell> in Angular? I want to add a new column in my Material table and keep it hidden, using it only for filtering purposes... My current table setup looks like this: <ng-container matColumnDef="email"> < ...

using jquery to trap anchor in unordered list items

This section is dedicated to the menu on the website. The code for this menu can be found in the _Layout.cshtml() page. When the 'Neu Gesellschaft' page loads, I want to change the CSS of the anchor tag a. I attempted the following jQuery code: ...

Techniques and Strategies for showcasing several images in close proximity

I am looking to arrange dummy images in a row next to each other, similar to the example shown here: https://i.sstatic.net/HUUGz.png Since my CSS skills are not very strong, I am seeking guidance on the proper way to achieve this. The images I have are a ...

The Bootstrap Dynamic Navbar is not adjusting for mobile devices because of the addition of a logo

Struggling to incorporate a logo into the navbar of my website. It looks good on larger screens, but causes the navbar to break on smaller screens. View without the logo: Click Here View with the logo and resizing issues: Click Here I think I can make th ...

Combining Redux Toolkit and React Query in a single project is a powerful duo

I have a burning question about React: is it advisable to incorporate both Redux Toolkit and React Query within a single project? The dilemma lies in my familiarity with both libraries. I possess knowledge regarding fetching data and implementing paginati ...

Using an npm package to include CSS styles in a stylesheet

I created an NPM package that includes a CSS file that needs to be included in my main CSS file. In a typical HTML CSS website, I would need to write @import url("./node_modules/web-creative-fonts/index.css") but what I really want is to simplify ...

What is the best way to retrieve an API response after submitting data?

Currently working on a React website with a node.JS REST API, I'm facing a challenge that I need help with. During the login process, my React form sends a POST request to my API. Since this is a School Project and I am working locally, my React app ...

Tips on creating a View with flexbox in a React Native component

Here is the layout I'm aiming for, with a focus on the products. This is what I tried: I created a component called "AllProducts" and set its flexDirection to row, then bound my Product Array to it. However, this was the result I got: Below is a sni ...

Part II: Material-UI - Finding the Right Source for CSS Classes

I have recently started diving into Material UI - Grid and this question is a continuation of my previous query about defining CSS classes for Material UI components, specifically the classes.root Sunny day with a chance of rain I made some changes b ...

`The universal functionality of body background blur is inconsistent and needs improvement.`

I've developed a modal that blurs the background when the modal window is opened. It's functioning flawlessly with one set of HTML codes, but encountering issues with another set of HTML codes (which seems odd considering the identical CSS and Ja ...

How can I effectively separate the impact of Next.js onChange from my onClick function?

The buttons in my code are not functioning properly unless I remove the onChange. Adding () to my functions inside onClick causes them to run on every keystroke. How can I resolve this issue? In order to post my question, I need to include some dummy text. ...

Creating CSS styles for fluid width divs with equal height and background images

Looking to create a layout with two side-by-side divs of equal width - one containing an image and the other dynamic text that can vary in height from 400px to 550px based on input. The goal is for the image to align flush at the top and bottom with the te ...

Designing a Dynamic Floating Element that Shifts with Scroll Movement

Hey there everyone!, I am currently working on a project in Wordpress and I was wondering if anyone has experience creating a floating widget that moves along with the page as you scroll. Any suggestions on how to achieve this? Would it involve using Javas ...