Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:52:05+00:00 2026-06-12T23:52:05+00:00

So this is what I want to do : I have a regular rectangle

  • 0

So this is what I want to do :

enter image description here

I have a regular rectangle image, and I want to be displayed as a rounded image. How can I do this?

(Image credit)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:52:07+00:00Added an answer on June 12, 2026 at 11:52 pm

    I hope I got this right:

    • you have a rectangular non-square image, something like this

      width > height

      (width > height) or like this

      height > width

      (height > width)

    • and you want to display it in a circle without distorting it,
      probably as much as you can display of it and the central part,
      something like this:

      in a circle


    Solutions:

    2023 solution

    Give the image either a width or a height an aspect-ratio of 1 (square) and set object-fit: cover on it.

    img {
      aspect-ratio: 1;
      object-fit: cover;
      border-radius: 50%
    }
    
    img:nth-child(odd) { width: 10em }
    img:nth-child(even) { height: 10em }
    <img src='https://images.unsplash.com/photo-1664985363388-0e4bd2b5cdb6?w=250'>
    <img src='https://images.unsplash.com/photo-1700587085844-b96c27958df2?w=250'>
    <img src='https://images.unsplash.com/photo-1699976971092-7c92ce87965d?w=250'>
    <img src='https://images.unsplash.com/photo-1702141258459-6dd8f817e79a?w=250'>
    <img src='https://images.unsplash.com/photo-1699031153161-b719847e2607?w=250'>
    <img src='https://images.unsplash.com/photo-1702121269747-fe91af4fa4a8?w=250'>

    Original 2012 solutions, preserved for web history reasons, but please don’t do this nowadays anymore

    When you know the size of the image it is really simple: you put it in a wrapper, give a wrapper a width and a height that are both equal to the minimum between the width and the height of the image itself. You then give the wrapper border-radius: 50%; and overflow: hidden;.

    Next, you position the image such that the central part is visible.

    • if the width of the image is greater than its height (landscape
      image)
      , then you set its left margin to be (height-width)/2
    • otherwise, if the height of the image id greater than its width
      (portrait image), then you set its top margin to be (width-height)/2

    demo

    Relevant HTML:

    <a href='#' class='circle-wrap'>
        <img src='image.jpg'>
    </a>
    

    Relevant CSS for landscape image (dimensions: 468px x 159px):

    .circle-wrap {
        overflow: hidden;
        width: 159px; height: 159px; /* height of img */
        border-radius: 50%;
    }
    .circle-wrap img {
        margin: 0 0 0 -154px; /* (height-width)/2 */
    }
    

    Alternatively, you could use a JavaScript solution (I’m suggesting this because you list javascript among the tags) if you don’t know anything about the orientation (portrait or landscape) of your image or about its dimensions.

    demo

    I’ve used a few images of different orientations sizes for testing. The HTML for one:

    <a class='circle-wrap' href='#'>
      <img src='image.jpg'>
    </a>
    

    Relevant CSS:

    .circle-wrap {
      overflow: hidden;
      padding: 0;
      border-radius: 50%;
    }
    .circle-wrap img { display: block; }
    

    JavaScript:

    var wrps = document.querySelectorAll('.circle-wrap'), 
        toCircle = function(a) {
          var style, w, h, img;
          for(var i = 0; i < a.length; i++) {
            style = window.getComputedStyle(a[i]);
            w = parseInt(style.width.split('px')[0],10);
            h = parseInt(style.height.split('px')[0],10);
            /* part that makes the wrapper circular */
            a[i].style.width = a[i].style.height = Math.min(w,h)+'px';
            /* part that takes care of centering imgs */
            img = a[i].querySelector('img');
            if(w > h)
              img.style.marginLeft = ((h - w)/2) + 'px';
            else if(w < h)
              img.style.marginTop = ((w - h)/2) + 'px';
          }
        };
    
    toCircle(wrps);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this regular expression in python: '<input type=hidden name=GALX value=(?P<galx>[a-zA-Z0-9_]+)>' I want an
Assuming I have this regular expression: '#artists/(.*)/#' and I want to match this string:
I have a regular expression [a-z][0-9][a-z][0-9][a-z][0-9] From this i want to generate a regular
I have this regular expression : ^(1?)(-| ?)(\()?([0-9]{3})(\)|-| |\)-|\) )?([0-9]{3})(-| )?([0-9]{4}|[0-9]{4})$ I want to
can you help me with this: I want a regular expression for my Ruby
i have this regular expression: <%(?<begintag>[^>]+)%>(?<inner>(.+?))<%/(?<endtag>[^%]+)%> what i want to achive is, check for
I have a regular expression like this: :%s/pattern/ pattern/gc As you can see in
I'm creating a simple form and in this form I want to have an
I want to have URLs like this: some-company-name-deal-id-6.htm So the rewrite rule should ignore
I want to have two columns on the bottom of this webpage I'm making,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.