Align the text in the center of the button vertically

Struggling to vertically center text on a button? I understand the frustration! I've been working on this issue for a whole day with no success. My setup involves NEXT.js and TailwindCSS.

<main>
  <div class='flex justify-center items-center h-screen'>
    <div class='bg-zinc-700 h-[610px] w-[340px] rounded-2xl flex justify-center'>
      <ul>
        <li>
          <div class='bg-black h-[100px] w-[275px] rounded-2xl shadow-2xl translate-y-11'></div>
        </li>
        <li>
          <div class='flex justify-center items-center h-[50%] translate-y-32 flex-row'>
            <ul>
              <li>
                <ul class='flex flex-row w-full'>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'><p class='inline'>c</p></button></li>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'>÷</button></li>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'>x</button></li>
                  <li class='text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'>+</button></li>
                </ul>
              </li>
            </ul>
          </div>
        </li>
      </ul>
    </div>

  </div>
</main>

<script src="https://cdn.tailwindcss.com"></script>

Appreciate any help!

Answer №1

Indeed, quite frustrating. One workaround is to adjust the position of the element by 0.25rem using a custom class (I created a class named .nudgeup and surrounded the symbols with p tags).

<style>
  .nudgeup { position:relative; bottom:0.25rem; }
</style>
<main>
  <div class='flex justify-center items-center h-screen'>
    <div class='bg-zinc-700 h-[610px] w-[340px] rounded-2xl flex justify-center'>
      <ul>
        <li>
          <div class='bg-black h-[100px] w-[275px] rounded-2xl shadow-2xl translate-y-11'></div>
        </li>
        <li>
          <div class='flex justify-center items-center h-[50%] translate-y-32 flex-row'>
            <ul>
              <li>
                <ul class='flex flex-row w-full'>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'><p class='inline nudgeup'>c</p></button></li>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'><p class='nudgeup'>÷</p></button></li>
                  <li class='pr-6 text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'><p class='nudgeup'>x</p></button></li>
                  <li class='text-3xl text-black'><button class='w-12 h-12 bg-gray-300 shadow-lg rounded-full'><p class='nudgeup'>+</p></button></li>
                </ul>
              </li>
            </ul>
          </div>
        </li>
      </ul>
    </div>

  </div>
</main>

<script src="https://cdn.tailwindcss.com"></script>

Answer №2

Give this a shot:

  .nudgeup { position:relative; bottom:0.25rem; }

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

Boosting Your SCSS (SASS) Productivity

I'm curious if there are any ways to make the code below more efficient or dynamic. I've already achieved the desired result, but I'm interested in optimizing it further. The Script Any suggestions would be highly appreciated, Cheers, ...

Creating uniform-sized flex items with varying image sizes

When setting flex: 1 1 0 on flex items, it does not work as expected especially when the flex items contain images of varying sizes. In this scenario, the flex-item containing the image ends up becoming significantly wider than the others. Below is the H ...

Create a layout using jquery-tokeninput

Currently, my project incorporates jQuery-tokenInput and everything is functioning properly. However, I now have the desire to customize the design of the results that are displayed. For example, I want to adjust the width or make any other design changes. ...

Having trouble grasping the error message "Uncaught Typerror Cannot Read Property of 0 Undefinded"?

As I embark on creating my very first ReactJS website with Node in the back-end, I encountered an issue in fetching and printing data. While I successfully displayed the names, pictures, and emails of project members from the server, I faced an error when ...

Combining numerous base64 decoded PDF files into a single PDF document with the help of ReactJS

I have a scenario where I receive multiple responses in the form of base64 encoded PDFs, which I need to decode and merge into one PDF file. Below is the code snippet for reference: var pdf_base1 = "data:application/pdf;base64,JVBERi0xLjQKJfbk/N8KMSAwIG9 ...

The alignment of inline divs is off and they are not forming a straight row

From my understanding, adding display:inline to divs with a relative position should align them (left to right) similar to float:left. I attempted both methods but with no success. Below is an example of my latest try with inline displaying. My goal is to ...

Using JavaScript (without jQuery), take away the CSS class from an element

Seeking assistance from experts on the process of removing a class from an element solely using JavaScript. Kindly refrain from suggesting solutions involving jQuery as I am unable to utilize it, and have little knowledge about its functionalities. ...

Styles from the Material-UI v5 Menu Component are not being implemented as expected

Struggling to customize the Menu component in Material-UI v5. This is my current UI layout: <Menu defaultValue={undefined} id="simple-menu" open={openMenu} onClose={onCloseHandler} anchorEl={anchorEl} ...

"Click to view the latest data visualization using the Chart.js

I am exploring ways to enhance the animations in Chart.js for a new web project. The content is organized in tabs, with the chart displayed on the third tab out of four. Currently, the chart animates upon loading. How can I make it so that when #chartTrig ...

Disappearing Bootstrap 3 Dropdown Issue Caused by Tab Click

There is an issue with the drop-down menu I created: When I click on tabs like ALL or FILM, it closes all elements. To reopen, I have to click again on the button PRODUCT.dropdown-toggle. The code example looks like this: var App = function () { ...

The Netlify build encountered an error: Command resulted in exit code 1 - To learn more about this issue, visit https://ntl.fyi/exit-code-1

Trying to deploy my portfolio on Netlify for the first time has been a learning experience. After researching and attempting to add "CI = npm run build" to build settings as recommended in various articles, I encountered an error that prevented successful ...

Is there a way to ensure that the div of my template spans 100% in width and height?

I'm attempting to make my div 100% in size but I am having trouble achieving it. Here is my code: <template> <div> <Navbar/> <Calendar/> </div> </template> <script setup> import Calendar from &apos ...

The width of the Div element is not following the specified dimensions, and it also has an unspecified margin

Check out my code snippet at: http://jsfiddle.net/8z4aw/ I'm trying to create a table-like layout using div elements, but for some reason the browser is not respecting the specified widths and seems to be adding an unwanted right margin. Where is thi ...

How to make the second div start on a new row when the first div exceeds its space in CSS

I am trying to figure out how to have two divs side by side with equal width. However, if the text in the first div wraps onto a second line, I want the second div to move below the first one and both divs should double in width. Can CSS handle this type o ...

Attention: Two children with identical keys were found, ""

In my current project, I am utilizing ReactJS, NextJS 14, Tailwind CSS, and Framer Motion. When working with React, it's essential to assign unique keys to each repeated child component. In my case, this requirement carries over to NextJS as well. To ...

Endless Cycle of Promise and useState Hook

I'm struggling with a situation where I unintentionally created an infinite loop using a combination of a fetch promise and a useState hook in React. Could someone shed some light on why this loop keeps repeating? My understanding of both concepts is ...

Can JSS support creating variables similar to Sass?

Currently, I am developing a project in React and utilizing Material-ui with JSS for styling. In Sass, we have the ability to define variables like $color: rgb(255, 255, 255) for later use. I am curious if it is possible to implement variable usage simi ...

Despite providing a type, Typescript continues to display an error claiming that the property 'children' does not exist on the type 'FC<ProvidersProps>'

I have set up the props interface, but I am still encountering an error. Property 'children' does not exist on type 'FC'. 'use clilent' import React, { FC, ReactNode } from 'react' import { Toaster } from 'rea ...

Is there a way to create a dropdown menu that transforms into a burger icon on smaller screens, while still housing all of my navigation items within it?

I'm currently working on a segment of my header that includes a navbar with 3 links, as well as a dropdown menu listing additional functionalities. Here is the current code I have: <div class="col-md-4 pt-4"> <nav class="navbar ...

Next.js is a powerful framework that allows for an infinite amount of nested dynamic routes

Having an issue in Next.js where I am trying to navigate to a URL with multiple dynamic nested routes and extract the values from each of them. For instance, I want to go to www.mysite.com/color/black/fit/slim/size/medium and retrieve the values for all th ...