Get rid of any vacant spaces in -translate-y by utilizing Tailwind CSS

I am experiencing an issue with some empty space in my profile container that I would like to have removed. The profile container is where the problem lies.

    <div className='h-auto w-[650px] z-10 rounded-xl' style={{ backdropFilter: `blur(400px)`, backgroundColor: bgColorWithOpacity }}>
    {user.Banner && (
        <div className='h-full w-full'>
            <img src={user.Banner} className='rounded-t-xl' alt={user.Username} />
        </div>
    )}
    <div className={`items-center grow flex flex-col z-20 ${user.Banner ? '-translate-y-24' : ''} px-8 py-8`}>
        <img src={user.Avatar} className='w-[128px] h-[128px] object-cover rounded-md' alt='' />
        <h1 className='mt-4 font-bold text-2xl'>{user.username}</h1>
        {user.Bio && (
            <p className='text-sm mt-2'>{user.Bio}</p>
        )}
    </div>
</div>

Answer №1

This code has been revised and updated

<div className='relative h-auto w-[650px] z-10 rounded-xl' style={{ backdropFilter: `blur(400px)`, backgroundColor: bgColorWithOpacity }}>
    {user.Banner && (
        <div className='relative'>
            <img src={user.Banner} className='rounded-t-xl w-full' alt={user.Username} />
            <div className='absolute inset-0 flex flex-col items-center justify-center mt-24'>
                <img src={user.Avatar} className='w-[128px] h-[128px] object-cover rounded-md' alt='' />
                <h1 className='mt-4 font-bold text-2xl'>{user.username}</h1>
                {user.Bio && (
                    <p className='text-sm mt-2'>{user.Bio}</p>
                )}
            </div>
        </div>
    )}
    {!user.Banner && (
        <div className='flex flex-col items-center px-8 py-8'>
            <img src={user.Avatar} className='w-[128px] h-[128px] object-cover rounded-md' alt='' />
            <h1 className='mt-4 font-bold text-2xl'>{user.username}</h1>
            {user.Bio && (
                <p className='text-sm mt-2'>{user.Bio}</p>
            )}
        </div>
    )}
</div>

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

Is there a way to ensure that the content of my modal dialog only displays once when it is opened?

While working with Chakra UI, I encountered a unique issue that I hadn't faced before with Material UI. The problem arises when using the Chakra UI modal dialog - all components inside it get rendered twice upon opening. Despite attempting to disable ...

I'm encountering an issue where Typescript is unable to locate the Firebase package that I

I have a TypeScript project that consists of multiple .ts files which need to be compiled into .js files for use in other projects. One of the files requires the firebase package but it's not being found. The package is installed and located inside t ...

Identify the classification of unfamiliar items

Occasionally, you may find yourself in situations where you have to work with packages that were not designed with TypeScript in mind. For instance, I am currently using the two.js package in a React project with TypeScript strict mode enabled. It has been ...

How to require 2 out of 4 input fields in Angular using typescript

exploring the intricacies of design decisions, sub systems, frameworks, and libraries Hello! I am relatively new to Angular and have encountered a puzzling issue that I can't quite figure out. I could easily create a lengthy if statement to address i ...

In JavaScript, constructors do not have access to variables

Currently, I am attempting to implement Twilio Access Token on Firebase Functions using TypeScript. export const generateTwilioToken = functions.https.onRequest((req, res) => { const twilioAccessToken = twilio.jwt.AccessToken; const envConfig = fun ...

Accessing a data property within an Angular2 route, no matter how deeply nested the route may be, by utilizing ActivatedRoute

Several routes have been defined in the following manner: export const AppRoutes: Routes = [ {path: '', component: HomeComponent, data: {titleKey: 'homeTitle'}}, {path: 'signup', component: SignupComponent, data: {titleKe ...

What could be causing the TypeScript class property to be undefined?

Below is the code snippet I am working with: class FeedbackController { public homePage(req, res){ this.test(); res.send('Welcome to feedback service'); } private test(){ console.log('test called'); } } export de ...

Tips for accessing the following element within an array using a for loop with the syntax for (let obj of objects)

Is there a way to access the next element in an array while iterating through it? for (let item of list) { // accessing the item at index + 1 } Although I am aware that I could use a traditional for loop, I would rather stick with this syntax. for (i ...

Activating the microphone device on the MediaStream results in an echo of one's own voice

I am in the process of creating an Angular application that enables two users to have a video call using the Openvidu calling solution. As part of this application, I have implemented a feature that allows users to switch between different cameras or micr ...

What is the best way to incorporate a @types module into a TypeScript file that is not already a module?

Setting the Stage: In the process of shifting a hefty ~3,000 line inline <script> from a web-page to a TypeScript file (PageScripts.ts) to be utilized by the page through <script src="PageScripts.js" defer></script>. This script entails ...

React: Implement a feature to execute a function only after the user finishes typing

Currently, I am using react-select with an asynchronous create table and have integrated it into a Netsuite custom page. A issue I am facing is that I would like the getAsyncOptions function to only trigger when the user stops typing. The problem right now ...

Encountering a bug in the comment feature of the next.js npm module

I encountered an issue that is giving the following error messages: 10:03:56.049 ./components/navbar.js 10:03:56.049 13:33 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/ ...

The ngFor directive in Angular should be used with the Filter pipe to ensure that

Having a Filter implemented in my Angular Project that fetches data from Firebase. The current status in the Filter is as follows: Name 1: Lea Muster Name 2: Bruno Mustermann Name 3: Lea Muster Name 4: Gabriela Musterfrau The goal is to show duplicate e ...

The onChange function in React is not behaving as I anticipated

Consider the following data structure for tables: an array of objects containing nested objects: [ { "1": { "1": "Item s ", "2": "Manufacturer ", "3" ...

Bringing in Chai with Typescript

Currently attempting to incorporate chai into my typescript project. The javascript example for Chai is as follows: var should = require('chai').should(); I have downloaded the type definition using the command: tsd install chai After refere ...

Troubleshooting: Next.js - Issues with encodeURIComponent function when using `/` in getStaticPaths

Reproducible site showcasing the issue: Reproducible code example: https://github.com/saadq/nextjs-encoding-issue Homepage Food page The goal is to dynamically create static pages for different food items based on their titles. This functionality works ...

"Firebase function fails to return Typescript class variable, resulting in 'undefined'

Being someone with a background in python/golang, I am now delving into ionic2. There seems to be an issue that I can't quite figure out due to my current level of knowledge in this stack. Perhaps I just need a way to reference the outer scope of this ...

The CORS Policy error message "The 'Access-Control-Allow-Origin' header is missing on the requested resource" in Next.js

Encountered an issue with CORS Policy error while attempting to redirect to a different domain outside of the project. For example, trying to navigate to https://www.google.com through a button click or before certain pages load. The redirection was handl ...

Avoid obtaining cookies within the TRPC environment

Recently, I've been setting up TRPC with Next.js and attempting to implement server-side rendering where I fetch user data before the page loads using the trpc.useQuery hook. However, I'm facing an issue where I cannot access the JWT token cookie ...

Exploring the integration of NextAuth's credential provider with Apollo Client

Encountered an error when using NextAuth for GraphQL authentication with Apollo client in Next.js: Hooks can only be called inside of the body of a function. import NextAuth from 'next-auth'; import Providers from 'next-auth/providers&apo ...