Tips for Aligning an Image Just Above a Card in Mobile and Tablet Screens with Tailwind CSS

https://i.stack.imgur.com/tPXEQ.jpg https://i.stack.imgur.com/3XkJo.jpg

Just a heads up, this code snippet performs well on desktop but may have some issues on mobile and tablet devices. If anyone in the StackOverflow Community can offer some assistance, it would be greatly appreciated.

     <div>
          <div className='justify-center mt-16 md:pb-6 lg:pb-0 lg:flex lg:mx-36 md:mx-auto rounded-2xl bg-neutral-800'>
            {/* Column 1 */}
            <div className="-mt-10 lg:relative">
              <Image
                src="/images/review/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bad3d7dbdddf97d0dfc8dfd7c397d6dbc8dddffa88c294cad4dd">[email protected]</a>"
                width={290}
                height={290}
                alt="people"
                className="w-56 mx-auto rounded-xl lg:w-72"
              />
            </div>
    
            {/* Column 2 */}
            <div>
              <Image
                src="/images/review/patternCurveDiagonalLine.png"
                width={60}
                height={60}
                alt="Curve Diagonal Line"
                className="mx-auto mt-10 lg:mt-32 lg:mx-14"
              />
            </div>
            {/* Column 3 */}
            </div>
          </div>
        </div>

Answer №2

When you set mt-16 in the parent div, -mt-10 is essentially subtracted from it, resulting in 16 - 10 = 6, which translates to mt-6 on mobile view.

To resolve this issue, simply remove mt-16 from the parent div.

Update your code as follows:

<div className='justify-center mt-16 md:pb-6 lg:pb-0 lg:flex lg:mx-36 md:mx-auto rounded-2xl bg-neutral-800'>

Change it to:

<div className='justify-center md:pb-6 lg:pb-0 lg:flex lg:mx-36 md:mx-auto rounded-2xl bg-neutral-800'>

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

Tips for preventing the mui autocomplete popup icon from spinning too much

Is there a way to prevent the search icon from spinning when the autocomplete input is opened? <Autocomplete popupIcon={<Search />} onChange={(e, value) => handleFound(value)} options={['0', '2', '3', '1 ...

I am curious to learn more about React (version 16.13.1) that I've implemented using the create-react-app tool

I recently received a catalog for my new program, but I'm struggling to comprehend the contents of these documents. ...

Restrictions on File Size in Express Server (Exceeding 50MB)

Is there a method to upload files larger than 50 mb on the express server? I keep encountering the file size limitation of 50 mb. Appreciate any help. Thank you. ...

"Engaging with the touchscreen inhibits the triggering of click

Within this div, I have implemented touch-action:pan-y;. Surrounding this div is an anchor tag. If you click on the div, the link will successfully redirect. However, if you swipe on the div and then click, the link won't work on the first attempt bu ...

QuickFit, the jQuery plugin, automatically adjusts the size of text that is too large

I have incorporated the QuickFit library into my website to automatically resize text. However, I am running into an issue where the text is exceeding the boundaries of its containing div with a fixed size. This is something I need to rectify. This is ho ...

Custom Email Template for Inviting Msgraph Users

I'm currently exploring the possibility of creating an email template for the MS Graph API. I am inviting users to join my Azure platform, but the default email they receive is not very visually appealing. public async sendUserInvite(body: {email: < ...

Utilize the grid system from Bootstrap to style HTML div elements

I am working on my angular application and need help with styling items in a Bootstrap grid based on the number of elements in an array. Here's what I'm looking to achieve: If there are 5 items in the array, I want to display the first two items ...

Having difficulty building a react.js application using Visual Studio 2019

Currently, I am following a helpful tutorial on creating a react.js application using visual studio. At this stage, the tutorial instructs me to open the command prompt and enter the following command: webpack app.tsx --config webpack-config.js (I have ...

What is the purpose of setting the Z-Index on a Popper menu

If you want to see a live example demonstrating the issue, head over to codesandbox.io. My goal is to create a 'sit below' menu just like it's shown in the Material-UI documentation here. return ( <div className={classes.root}&g ...

Tips for transforming a JSON object (originated from jquery-css-parser) into properly formatted CSS code

Currently, we are utilizing a jQuery plugin in our project to convert CSS to a JSON object. The plugin can be found at the following link: Now, we have a requirement to convert the JSON object back to CSS in string format. Unfortunately, the plugin we ar ...

How can I make my image shine when the mouse hovers over

I have recently come across a fascinating effect where an image glows up when the mouse hovers over it. This is not your typical border glow, but rather a unique enhancement of colors within the image itself. I discovered a library called Pixastic that can ...

New in Material UI V5: The createTheme Palette now exclusively applies to primary and secondary colors

After successfully creating a palette with primary and secondary colors, I ran into an issue when trying to pass the info tag. palette: { mode: 'dark', primary: { main: darkprimaryColor, }, secondary: { main: d ...

Using the ternary operator will always result in a TRUE outcome

Having trouble with a ternary operator expression. AssociatedItemType.ExRatedTag ? session?.data.reloadRow(ids) : this.reloadItemRows(this.prepareItemsIdentities(ids)!), The AssociatedItemType is an enum. I've noticed that const ? 1 : 2 always retur ...

Having difficulty loading data from a JSON object into a React Select dropdown

I am currently struggling with populating a react-select dropdown using a JSON object. Below is the code for reference. Any assistance would be greatly appreciated. import React, { useState, useEffect } from 'react' import Select from 'react ...

Issues launching local server with NPM Start

I am currently working on a React app using webpack, but when I attempt to run npm start, it is supposed to load http://localhost:3333. However, the browser displays an error message saying that the site cannot be reached. Below is my webpack configuration ...

"Why does the font on my website look different on my computer before I upload it to my web host? How can I fix

I am currently developing a website and have chosen the font "PT Sans Narrow" for it. Unfortunately, it seems that Chrome and many other browsers do not support this font by default. Is there a way to include the PT Sans Narrow font with the website when ...

Issue with scrollable multilevel dropdown menu

Dealing with an extensive menu list, I aimed to restrict them using a scroll. In the demo on CodePen, everything works fine without the scroll. However, upon adding overflow-y:scroll; height:200px;, it leads to an overflow-x issue and hides all the dropd ...

Differences in the way websites scroll on Chrome compared to Safari and Firefox

Currently, I am in the process of developing a rendering system for my application that extracts objects from a collection and processes them through JavaScript templates to generate additional children as the user scrolls through the page. The system is d ...

Styling Dynamic HTML Content in Angular: Tips and Tricks

After running this line of code, I have a generated element sub with a property of [sub]. <li [displayMode]="displayMode" template-menu-item style="cursor: pointer" [routerLink]="['/request/checkoutReview']" icon="fa-shopping-cart" name ...

Bone structure template - optimizing list spacing with CSS

Currently, I am attempting to float my navigation bar further towards the left by at least 200px, closer to the end of the line visible below. However, every time I add a margin or padding, it causes the elements within the navigation bar to stack on top o ...