What is the best way to position a button on the right side of the page, ensuring that all text

I need help aligning my button (JSX component) to the right side while ensuring that all text remains on a single line. I am working with next.js and tailwindcss, and the button includes plain text as well as a react-icon. These components are all wrapped within a card.

Currently, this is what I'm seeing:

This is my current code for the card component:

return (
<Fragment>
  <div className=" bg-white rounded-md text-black overflow-hidden ">
    <img className="object-cover w-full h-48" src={"/" + image}></img>
    <div className=" flex-none" id="text">
      <div>
        <h1 className=" text-3xl font-semibold">{title}</h1>
      </div>
      <div>
        <p className=" text-gray-700 font-bold">{humanReadableDate}</p>
        <p className=" text-lg italic text-gray-500">{formattedAddress}</p>
      </div>
      <div className=" m-3">
        <Button link={"/events/" + id}>
        <span className="inline">Explore event</span>
        <span className="inline"><AiOutlineArrowRight /></span>
        </Button>
      </div>
    </div>
  </div>
</Fragment>
);

And here's the code for the button component:

return (
<Link href={props.link}>
  <a className="inline-block text-right bg-emerald-500 text-white py-2 px-5 rounded-md">{props.children}</a>
</Link>
);

Answer №1

Explore the concept of floating elements

Learn how to use float-right to align an element to the right side of its container.

Dive into the topic of sizing elements

Discover utilities for defining the minimum width of an element (e.g. min-w-max).

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

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 ...

What is the best method to prevent next.js components from overlapping one another?

I recently created a website using next.js and noticed an issue in my index.js file. There is a div that houses the main components of the site: class Page extends Component { render() { return ( <div className={styles.container}> ...

When running the npm build command, an error regarding image optimization is encountered

New to Next.js, I recently created a basic landing page and tried to generate a static page using npm run build with the command "build": "next build && next export" in my package.json file. However, I encountered an error: Error: Image Optimization using ...

Position the final list item in the column on the left side

Currently, I am facing an issue with creating spacing between li elements in a column layout. The problem arises when the last li in the column does not align to the far left edge of the column width. Take a look at the screenshot below for reference: Bel ...

Entering in full screen mode

Is there a way to create a first screen appearance that spans the entire screen? I want the whole page to be fullscreen and when someone scrolls down, it transitions to a new screen. I am struggling to find a solution for this. body { margin: 0 0 0 0; ...

"Utilizing both onClick event handling and the type=submit attribute in a React webpage

In my Next.js application, I have a React form with reactstrap that includes a submit button setup like this... <Button type="submit" className="btn btn-block" disabled={!pwFormValidations.pwIsSubmittable} onClick={(e) =& ...

Exploring the use of getServerSideProps within a React context (specifically within the Next.js pages

I am facing a dilemma while working with Next.js and the pages router. The issue revolves around managing the global context of my application using react createContext. My requirement is to fetch data using getServerSideProps and store the result in a gl ...

Is there a way to turn off step navigation in bootstrap?

Displayed below is a visual representation of the bootstrap step navigation component. Presently, there is an unseen 'next' button located at the bottom of the page. When this 'next' button is pressed, it transitions from 'step-1 ...

Creating evenly spaced PHP-generated divs without utilizing flexbox

My goal is to display images randomly from my image file using PHP, which is working fine. However, I am facing an issue with spacing the images evenly to fill the width of my site. This is how it currently appears: https://i.stack.imgur.com/AzKTK.png I ...

Display my search box when the button is activated

I have a button labeled "Search" that I want to click in order for my search field (which is currently hidden with display:none) to become visible. However, my current setup is not working as intended. I have created a jsfiddle to illustrate my issue. Al ...

What is the best way to access attributes from a div element?

I am currently working on extracting attributes from within a div tag, specifically the custom attributes of the first child element. I am using web scraping techniques with Node.js and Puppeteer. My goal is to retrieve the custom attributes data-ticker, d ...

CSS: Create a form with two input fields where the left field is adjustable in width and the right field fills up

------------- -------------------------------------------------- | some unique text | | some more original content, varying length | ------------- -------------------------------------------------- |<---------------------- 100% width ------------------ ...

Exploring the latest features in React V18 alongside Next.js V12.3.1 - Leveraging Suspense boundaries, StartTransition, and the innovative createRoot

I've been exploring how to make a react app work with next js. Currently, I'm utilizing this boilerplate app template, but with react v18 (and next v 12.3.1). In my attempt, I modified _app.tsx so it's now enclosed in a suspense boundary: ...

The jQuery menu is malfunctioning in Internet Explorer due to the Document Mode being set to Quirks

I am encountering an issue where the below code is not functioning properly in Internet Explorer's document mode quirks. Each time I hover over the submenu, its length doubles unexpectedly. Can someone please provide assistance with this matter? < ...

Aligning text in a vertical progress bar using absolute positioning

Currently, I am trying to create a health bar-like element but I am facing difficulties in centering the text within it. Despite exhausting all my options, the text is either off-center when its length changes or extends beyond the borders of the bar. Her ...

What are some tips for designing HTML email templates?

Check out this example of an HTML email <div style="width:650px;"> <div class="begining"> <p> Dear <span>' . $name . '</span><br/>Thank you for your booking </p> & ...

Personalized form outlines

I'm designing a Valentine's Day theme for my website and I was wondering if it's possible to create custom form borders, like a heart shape, without having to hard-code everything. I could always insert an image where needed, but that seems ...

Incorporate text onto an image using Semantic UI

Currently, I am utilizing Semantic UI to display images. While it is functioning well for me in terms of adding text near the image, I desire to have the text positioned on top of the image. Ideally, I would like it to be located on the lower half of the i ...

What is the best way to prevent the span text from wrapping to the next line depending on the content of the previous span element using CSS?

i want to ensure the span elements text remains fixed to two lines within a flexbox. What is my goal? https://i.stack.imgur.com/k0GhL.png I am aiming to achieve something similar to the image above. The issue arises when the value in '/400' be ...

Is it possible to show the Display Center within the dropdown menu?

Hello everyone, this is my first time posting on stackoverflow. I have a question about centering the select options. Could someone please take a look at the image attached and let me know if it's possible? <select multiple="multiple" nam ...