What could be preventing the border-radius property from applying to the image?

Click here to view the image

I've exhausted all options but still can't get the border radius to work on this particular image. It just refuses to respond to any changes I make, whether it's in percentage or pixels. Every other CSS property seems to be working fine except for border-radius. I'm at a loss for what else to try.

Take a look at the component code below:

import React from "react";
import {
  UserContainer,
  User,
  UserProfilePicture,
  UserProfileName,
  UserChevronIcon,
} from "./User.style";
import Logo from "../../../images/ProfileFace.jpg";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faChevronDown } from "@fortawesome/free-solid-svg-icons";

function UserProfile() {
  return (
    <UserContainer>
      <User>
        <UserProfilePicture>
          <img src={Logo} height="50" width="50" border-radius="50px" />      -----> both px and % don't work
        </UserProfilePicture>
        <UserProfileName>Olivia Wilde</UserProfileName>
        <UserChevronIcon>
          <FontAwesomeIcon icon={faChevronDown} color="#7a7e7e" />
        </UserChevronIcon>
      </User>
    </UserContainer>
  );
}

export default UserProfile;

And here is the styled component code:

import styled from "styled-components";

export const UserContainer = styled.div`
  height: 90%;
  width: 30%;
  margin: 0px;
  padding: 0px;
  background-color: inherit;
  color: white;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
`;

export const User = styled.div`
  height: 70%;
  width: 100%;
  background-color: inherit;
  display: flex;
  text-align: end;
  justify-content: space-around;
`;

export const UserProfilePicture = styled.image`
  height: 50%;
  width: 50%;
  border-radius: 100px;      -----> both px and % don't work
  display: flex;
  justify-content: center;
  align-items: center;
`;

export const UserProfileName = styled.div`
  height: 40%;
  width: 40%;
  color: #7a7e7e;
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: flex-start;
`;

export const UserChevronIcon = styled.div`
  height: 50%;
  width: 10%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
`;

Answer №1

If you want to transform that image into a circular shape, simply adding a 100px border-radius to a 50px image won't achieve the desired effect. Instead, consider using percentages. For instance, to create a round appearance for a square image, apply the following style:

border-radius: 50%;

If this approach doesn't produce the expected result, it's possible that another CSS style is superseding it. In such cases, try using the !important tag:

border-radius: 50% !important;

If these methods still don't work (potentially due to another overriding !important tag elsewhere in your css), attempt styling it directly within the element:

<img src={Logo} height="50" width="50" style="border-radius: 50%" />

Answer №2

To customize the appearance, implement the code snippet below:

   <img src={Logo} height="50" width="50" style={{borderRadius: '50%'}}/>

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

What is the method to reach the parameter of a sass mixin?

Currently, I am working on a sass mixin with the following structure: @mixin hello($arg1, $arg2, $arg3) { // content here } The challenge I am facing is to dynamically access the number of arguments within this mixin (in this case, it should be 3) in ord ...

Aligning text appears fine in a full screen browser, but it can cause inconsistencies in appearance when resizing the window or viewing on a phone, as demonstrated in the

Hi there, I'm new to web design and I'm struggling to make my site look good on all screen sizes. I've created a page that should work well on any screen size: https://jsfiddle.net/garixakor/j0xck25v/1/ I attempted to center one of the par ...

Enhance the functionality of jQueryUI sortable by enabling scrolling and incorporating a delay specifically for mobile

I have an inline thumbnail gallery that can be sorted using jQueryUI and the touch punch plugin for mobile devices. Everything is functioning correctly, except on mobile devices with a large number of images. I am unable to scroll down the screen to view ...

Tips for ensuring text on an image dynamically resizes based on the browser's dimensions

Is there a way to keep text centered over an image when resizing the browser window to ensure responsiveness? I've tried positioning the text as an absolute element, but it keeps overflowing the boundaries of the image. How can I prevent this? .b ...

Positioning a div with text over an image in a way that it

Hey everyone, I've run into a bit of an issue with my project. I'm trying to create a system where text appears over an image, but the problem is that my div is set to absolute position and I can't switch it to relative without causing major ...

Why is there a thin line still visible on the other sides when a transparent background is used, but only on mobile devices, with a curved border on one side?

Recently, I've delved into the world of creating CSS art and stumbled upon a peculiar issue with CSS borders that has left me puzzled. When I apply a border to only one side of an element with a transparent background and rounded edges, I notice a fa ...

Verify whether a specific value exists in my React array; if it does, display a specific component

I need to display different components based on the following criteria: Whether the items contain a specific value And if all 10 items have that value const DisplayComponents = ({ data }: Props) => { const filteredItems = data.items?.filter( ( ...

What is the best way to use CSS to center a div on a webpage?

I am trying to position the div.father in the center of the screen, and then center the div.son within the div.father. Here is a visual representation of what I want: https://i.sstatic.net/6gsHb.png Can anyone help me rewrite my CSS code to achieve this ...

Button-operated lightbox image slider

I am currently developing a website on WAMP where users can store images and view them in a lightbox effect. I have successfully implemented the lightbox effect, but I am facing challenges with moving between images within the lightbox. <html> <? ...

Instructions to only input numbers or leave the text field blank

Hey there! I have implemented a directive that allows only numbers in my text field: Here is the HTML code snippet: <form name="filtroForm"> <input id="idMatricula" type="text" class="form-control" ng-model="filtros.Matricula" maxlength="20" ...

Issue with prop inheritance in componentInheritance problem with passing props to

How can I pass the state function setMyChoice as a prop to the GamePlay component in a rock paper scissors Nextjs application? The goal is to produce a value for comparison. In the Gameplay component, I then pass a prop to another component called PlayButt ...

Mac users may experience lag when using Javascript parallax effects

I created a parallax page where the background image changes using JavaScript translateY(- ... px)' similar to what you see on the firewatch website. On Windows, the parallax effect works smoothly. However, on macOS it is smooth only in Safari. All ...

What is the best way to decrease the border width of a chartjs doughnut chart?

I have a vision for my chart based on the mockup: However, here is what I've been able to achieve using chartjs so far: This is the code I'm working with: datasets: [ { data: [3, 8, 13, 9, 2], backgroun ...

How come the date is not showing up inside the <p> tag?

Check out this snippet of HTML code: <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="bootstrap_4.5.0&bsol ...

Display data from the current month for a specific ID in MySQL and present it in HTML tables based on ascending or descending order

Database connection successful. In my database, I have a table called "meal" and I am using the following SQL code: $sql = "SELECT * FROM ( SELECT date, month, day, breakfast, launch, dinner, meal_total, note FROM meal WHERE stid='$_SESSION[stid]&ap ...

Is it possible to utilize CSS alone to change the color of a certain image to white against a black background?

I specialize in crafting dark theme versions of popular websites using CSS. One challenge I often face is dealing with images like the ones below: https://i.sstatic.net/ZLpPT.png https://i.sstatic.net/2NKRP.png Websites typically use background-image t ...

Working with Python and BeautifulSoup to retrieve <td> elements in a table without specified IDs or classes on HTML/CSS documents

While utilizing Selenium, Python, and Beautiful Soup to scrape a web page, I encountered the challenge of outputting table rows as comma-separated values due to the messy structure of the HTML. Despite successfully extracting two columns using their elemen ...

Challenges with creating a contact form using bootstrap modal

I'm facing an issue with a bootstrap modal contact form. It works fine on all browsers except for iPad/Safari. Can anyone help me figure out what's wrong? On iPad, the modal is positioned to the right and down the page instead of in the cente ...

Caution: The @import directive should come before any other statements (except for @charset)

I'm currently working on an Angular app, and although there are no errors being displayed when running the app, I am consistently encountering warnings in various CSS files. Module Warning (from ./node_modules/postcss-loader/src/index.js): Warning ( ...

When the user clicks, show a designated search result in a separate container

I've been developing my Angular cocktail application, and I've reached a point where I can display all the cocktails in my database (only showing names). Now, I want to implement a feature where if I click on a specific cocktail, its full content ...