Home > Blockchain >  Aligning Image to the Right w/ Styled Component ReactJS
Aligning Image to the Right w/ Styled Component ReactJS

Time:11-10

I'm fairly new to ReactJS and am using styled components to display an image. The code I have in my App.js is <StyledImage src={mainimg} alt="hi"></StyledImage> which displays an image on the left side of the screen. My styling is

export const StyledImage = styled.img`
  width: 80%;
`;

I've tried justify-content, alignitems... I'm not sure what exactly to type to get it aligned on the right side of its container. Any advice?

CodePudding user response:

Ok so, you need to set the justify-content and align-item properties to the parent node of your image to move the child inside your parent. If you don't want to set any properties to the parent then use the position: absolute or position: fixed to your image.

CodePudding user response:

Use float: "right" as a style.

  • Related