What's the reason for the align-self: flex-end CSS property not working as expected on a flex div element?

I am trying to align the "Click me" button to the left of the div that contains it.

Here is my code:

render = () => {
    return (
        <Wrapper>
            <Body>
                <span>Title</span>
                <Description/>
                <ChildComponent/>
            </Body>
            <Actions>
                {((condition1 && !condition2) || !condition1) && (
                    <ActionText>
                        Hide 
                    </ActionText>
                )}
                {condition1 ? (
                    condition2 ? (
                        <ButtonLink href="dddd">Click me</ButtonLink> // I want this                              //to be displayed at the extreme right of Actions div
                    ) : (<ButtonLink href="ee">Add</ButtonLink>)
                ) : null}
            </Actions>
        </Wrapper>
    }

const Wrapper = styled.div`
    position: fixed;
    overflow: auto;
    display: flex;
    flex-direction: column;
`;

 const Body = styled.div`
     display: flex;
     flex-direction: column;
 `;

  const Actions = styled.div`
      display: flex;
      flex-direction: row;
      justify-content: space-between;
  `;

   const ButtonLink = styled.a`
       display: flex;
       justify-content: center;
       align-items: center;
   `;

I am struggling with getting the "Click me" button to show up at the far right within the Actions div. Using align-self: flex-end on the ButtonLink element did not work for me. However, applying margin-left to the ButtonLink successfully moved it.

I really prefer using flex-end to achieve this alignment. Can anyone provide assistance in resolving this issue? Thank you.

Answer №1

Implementing align-self: flex-end; will specifically align an element vertically (up and down, figuratively speaking). It may be tricky to grasp without a visual representation, but you can try applying flex-end to your Actions.

  const Actions = styled.div`
      display: flex;
      flex-direction: row;
      justify-content: flex-end;
  `;

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

The functionality of jQuery .Show() may be affected when a negative margin is present in the

Check out this demo on Codepen that showcases the issue: http://codepen.io/theclarkofben/pen/xKhsd The .Show() effect isn't working as expected due to the negative margin applied to the div. Can someone shed light on why this behavior is occurring? ...

Having an excessive amount of CSS Sprites or none at all can be detrimental to your website's performance

UPDATE: Attempted to adjust the height to 27px as recommended by kennypu, but still facing issues. I am working with a sprite containing multiple icons that I want to extract for navigation purposes. Unfortunately, I'm struggling to properly display ...

When the HTML code is rendered in a web browser, the CSS styles are not being

I am utilizing adminer within a docker container. When testing services, I utilize the URL mydomain.tld. In order to interact with this container directly, one option is to expose and map a port, such as mapping port 8081 to the adminer port 8080. Access ...

Implementing React Hook form validation on textfield input change in React

form that needs validation I am attempting to validate this form using React Hook Forms with Material-UI text field components. The issue is that it currently validates the form on submit, but I require validation to occur upon changes in the text field. ...

Troubleshooting a Netlify build error on a create-react-app website

Encountering: Build script returned a non-zero exit code: 1 After deploying my react js website code using Netlify, I received a build log along with the following error: 10:37:15 AM: Preparing to start the build 10:37:16 AM: Using build-image version: ...

Tips for Implementing Multi-Level/Nested in Ajax Requests

I am currently developing a user-friendly web application with intuitive multi-level options that loads new content without the need to refresh the entire page. This is how my structure looks: /index.php /schools.html /colleges.html Within schools.html, ...

What could be causing the space between float and div elements?

Could someone shed light on the reason behind the minor gap between the top navigation element and the content div underneath it in this jsfiddle? When I float the navigation list items, a slight gap appears between the top navigation element and the main ...

What is the best method to style a child input element's placeholder using Tailwind CSS?

I'm currently working on a project and trying to translate a CSS style that targets the ::placeholder pseudo-element into Tailwind CSS. However, I have encountered some challenges during this process as I'm not entirely sure of the correct approa ...

Retrieving queries from a sibling component using react-query: A step-by-step guide

I have a question regarding how to refetch a query from another sibling component using react-query. Let's consider Component A: import {useQuery} from "react-query"; function ComponentA(){ const fetchData = async () => data //re ...

New feature in NextAuth.js: Credentials authentication with reset password functionality included

Currently, I am working on a login system using next/auth with credentials logging system and an invitation-only feature. Is there a way to include a Reset Password link on the generated /api/auth/signin page? ...

Troubleshooting: AppBar Logo Display Issue with Material UI and React

There seems to be an issue with the logo not displaying on my AppBar. Here is the code I have: import { AppBar, Toolbar, Typography, makeStyles, Button, IconButton, Drawer, Link, MenuItem, } from "@material-ui/cor ...

In Next.js, encountering an error when using canvas drawImage

I am attempting to upload a local image onto a canvas element, but I keep encountering an error: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement ...

Can you explain the conflict between using float and setting the height to 100% for divs?

Check out the following HTML code example: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> html, body { padding: 0; m ...

Issues with rapid refreshing are arising in Vite while dynamically importing components with React and typescript

In my quest to develop a multistep form, I have organized my data in a separate file for constants as shown below: import { lazy } from 'react'; export const steps = [ { id: 0, name: 'Personal Info', component: lazy(() ...

Using React to pass a value through state when handling changes

Trying to implement handleChange and handleSubmit methods for a login page in React. Set username and password values in state, update them when form inputs change, then submit using the updated values. However, values print as undefined in the console. N ...

Is it common for material-ui and react to exhibit different behavior following the `npm run build` command?

I’m currently in the process of developing a content library using React-app with create-react-app. Here’s a look at the configuration in my package.json: { "name": "demo", ... } After running yarn install && yarn start, everything appear ...

Discover the most helpful keyboard shortcuts for Next.js 13!

If you're working with a standard Next.js 13 app that doesn't have the experimental app directory, setting up keyboard shortcuts can be done like this: import { useCallback, useEffect } from 'react'; export default function App() { c ...

Leveraging the Power of SASS Variables Across Your Entire NativeScript Application

Currently, I am in the process of developing an app using NativeScript 6.4.1 along with Angular 8. In order to enhance my styling capabilities, I have decided to incorporate SASS due to its advantageous features like variable names. My designer has suppli ...

Is NextJS on-demand revalidation compatible with Next/link?

https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#on-demand-revalidation According to the NextJS documentation, it appears that on-demand cache revalidation should function properly with regular <a> tags and when t ...

Using Axios to Integrate an API - Displaying a Username and Password Pop-up

I have been given a project that involves API integration. I have successfully retrieved data from the API, but there is a pop-up appearing asking for a username and password. Although I have these credentials, I would like to log in without that pop-up ap ...