What is the best way to align a circular image using CSS?

Having an issue with positioning a rounded image to the left of a webpage. Despite trying various methods, the image ends up flat with its corners missing and positioned on the right side instead of the intended left. I've scoured the internet for answers but haven't been able to pinpoint the problem.

Here is the CSS code I've been using:

.family{
  background: white; 
  overflow: hidden;
  min-height: 100vh;
}

.family img{
  position: relative;
  object-position: 20px 100px;
  top:50%;
  left:50%;
  width:50%;
  height:50%;
  border-top-left-radius: 50% 50%;
  border-top-right-radius: 50% 50%;
  border-bottom-right-radius: 50% 50%;
  border-bottom-left-radius: 50% 50%;
  object-fit: contain;
}

And here is the HTML code:

<div class="family">
        <img src="img/family.jpg">
</div>

Here is the image for reference: https://i.sstatic.net/q3zDp.png

Answer №1

After removing the style object-position: and adjusting the values of top and left to 0, the issue was resolved. You can see the updated code below:

.family{
  background: white; 
  overflow: hidden;
  min-height: 100vh;
}
.family img{
  position: relative;
  top:0;
  left:0;
  width:50%;
  height:50%;
  border-top-left-radius: 50% 50%;
  border-top-right-radius: 50% 50%;
  border-bottom-right-radius: 50% 50%;
  border-bottom-left-radius: 50% 50%;
  object-fit: contain;
}
<div class="family">
        <img src="https://thenextscoop.com/wp-content/uploads/2018/03/5-Mind-Blowing-Facts-from-the-Google-Logo-Design-History-1280x720.png">
</div>

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

Incorporate multiple array values within an if statement

Looking to dynamically change the background image of an element based on specific strings in the URL. Rather than changing it for each individual term like "Site1", I want to be able to target multiple words. Here's what I've tried: var urlstri ...

What is the process for including echo HTML field in the WooCommerce order view?

I have successfully added HTML input fields within functions.php. However, these echoed fields are not displaying in WooCommerce orders after placing an order. I am looking for a way to include the values and labels of these fields in the orders view wit ...

Displaying a large image within a small div using Bootstrap 4

I have a specific image with dimensions of 244px by 751px, and I am trying to place it inside a div container that is 132px by 132px. I want the image to maintain its aspect ratio without being stretched. Despite using the img-fluid class, the image does n ...

Troubleshooting layout problems caused by positioning items at window height with CSS and jQuery

At this moment, my approach involves utilizing jQuery to position specific elements in relation to the window's size. While this method is effective when the window is at its full size, it encounters issues when dealing with a debugger that's ope ...

Difficulty encountered when trying to update a re-updated HTML DOM using Flask

I have a flask dropzone for file uploads, and after each upload I want to display a log text on the website. While it currently works, there is an issue where the log text does not update after the second upload. The website continues to show the text from ...

Obtain data using a REST request from a webpage or web server

Is it possible to extract the last status value from a delivery courier's webpage by sending a tracking number request using PHP? I have found some helpful information, but I am unsure if it is possible to extract only specific values from the result ...

The ASP.Net email contains a hyperlink designed to open in a new window

I am currently facing an issue with an email I need to send. The problem lies in the hyperlink that is intended to open a specific page in a new tab or window upon clicking. The main issue at hand is that there is no space between the querystring variable ...

"Converting jQuery Form into a Wizard feature with the ability to hide specific steps

I'm working on a form where I need to hide a fieldset when a specific event is triggered. Inside the first fieldset, there is a select tag and when a certain option is selected, the second fieldset should be hidden. <form id="form1"> <fi ...

Basic image slider featuring adjustable heights

I'm currently working on a basic content slider, but I've encountered an issue where the container doesn't expand as new content slides in. It seems to be related to the absolute positioning of the content items. If I don't use absolute ...

Unable to input text in Vue.js text field

Recently, I encountered an issue while working on a new form using Laravel/Vue to input an address. Strangely, I found myself unable to type anything in the text input fields. Despite trying various solutions and seeking help from Google, the problem persi ...

Issue with HTML While Utilizing wp_get_attachment_image

This script : $source = wp_get_attachment_image( get_the_ID(), 'medium' ); $weburl = wp_get_attachment_image_url( get_the_ID(), 'full' ); echo( '<p><a href="%s"><img src="%s"></a></p>', $weburl, ...

Converting text into HTML format using Nextjs and React

Currently, I am working on a project that involves using Next.js and React. I am considering creating my own component to parse text based on certain conditions, but I am unsure if something similar already exists. My goal is to: Format the content in HT ...

Revamping CSS for a Responsive Wordpress Tesseract Theme

I'm currently in the process of developing a website using the Tesseract theme at thevandreasproject.com. However, I have encountered an issue with responsiveness when integrating the SiteOrigins PageBuilder plugin. The compatibility between PageBuild ...

Tips for navigating an aframe scene on mobile devices

How can I enable scrolling over aframe on mobile devices? I attempted to disable the scene controls but scrolling still doesn't work; the scene keeps interacting instead. ...

What is preventing the Selenium WebDriver from clicking on elements, despite their presence and focus?

Once again, I am facing a Selenium issue. Last week everything was running smoothly, but today when I attempted to write some new tests, I encountered a strange problem. Every time I try to click on something, Selenium seems to ignore the click. Even wit ...

Issue with calculating positions in the jquery.quicksand plugin

I've been playing around with a website for the past couple of days and I have successfully implemented the jquery.quicksand plugin to organize my portfolio entries. However, I've run into an issue when selecting the 'all' filter. If a ...

Adjust the height of an element when the maximum height is set to none

I am trying to add animation to the opening of a menu on my website. This is achieved by adjusting the max-height property of the <div> element that represents the menu, as well as changing the display property. The max-height value is being changed ...

Ensure that the content inside the centrally aligned div is also aligned at the

Looking for a way to center a box on a website I'm designing? Instead of aligning it based on existing centering, use the following HTML / CSS code to ensure that the white box is perfectly centered on the page. .loading { position: fixed; z-in ...

Bootstrap's nested grid system allows for intricate and dynamic layouts within

I am looking to design a grid with two columns, where on small and larger screens the width of the right column adjusts itself to accommodate its content, while the left column takes up the remaining space. On extra small screens, the layout changes to two ...

Determining the height of a jQuery mobile page

Struggling for the last 24 hours to adjust the min-height styling on a jQuery mobile page specifically for mobile safari. Despite trying various methods like inline styles and overriding ui-page styles, I have not been successful in changing the height of ...