Encircling the complete image within a circle

.circle_border {
    width: 125px;
    height: 125px;
    position: relative;

    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    -ms-border-radius: 50%;
    -o-border-radius: 50%;
    border-radius: 50%;
}
.Text{
font-size: 18px;
padding: 10px 0px 0px; 
line-height:normal;
}


.images1 {
    display: inline;
    margin: 0 auto;
    height: 125px;
    width: auto;
    border: 4px solid #FFF;
    border-radius: 62.5px;
}

.circle_border:hover .images1 {
   background: transparent;
border: 4px solid #67508F;
cursor: pointer;
color: transparent !important;

margin-top:4px;

/*{Shadow}*/
box-shadow:inset 0 0 5px 0 #333;
-moz-box-shadow:inset 0 0 5px 0 #333;
-webkit-box-shadow:inset 0 1px 2px 0 #333, 0 1px 1px 0 #fff;
} 

.circle_border:hover .Text {
cursor: pointer;
color:#67508F !important;
}
<div class="circle_border">
<img src="doctor.png" class="images1 zoomIn" alt="Save icon"/>
<p class="Text">
Doctor</p>
</div>

I'm trying to place the image below inside a circle with a width of 125px, but the image is being cropped. How can I ensure that the entire image fits inside the circle? You can view the image here.

I've defined a class called circle_border to create the circle and an image class to adjust the height and width of the image.

.circle_border {
    width: 125px;
    height: 125px;
    position: relative;

    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    -ms-border-radius: 50%;
    -o-border-radius: 50%;
    border-radius: 50%;
}
.images1 {
    display: inline;
    margin: 0 auto;
    height: 125px;
    width: auto;
    border: 4px solid #FFF;
    border-radius: 62.5px;
}

Answer №1

Here is how you can achieve it:

div {width: 125px;
    height: 125px;
    border: 1px solid;
    border-radius: 50%;
    position: relative;
    background: #ccc;}

img{width: 65%;
    position: absolute;
    top: 10px;
    left: 22px;}
<div>
  <img src="https://i.sstatic.net/6snp2.png">
</div>

Answer №2

Follow these instructions:

.round_image img{
   display: block;
   max-width: 100%;
   height: auto;
   border-radius:50%;
}

Answer №3

To enhance the appearance of your image-wrapper, it's advisable to define the properties for border, border-radius, and size. For the image itself, simply set the width to 100%. This approach grants you full authority over the block styling through the wrapper.

Take a look at the JSFiddle example

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

I can't seem to get my JavaScript to connect to my HTML file. What should I do next?

I'm facing a major issue at the moment. My HTML file doesn't seem to be linking properly with my JavaScript file, even though they are located in the same folder. The script link is correctly placed in the HTML file, but for some reason, it just ...

Displaying negative values highlighted in red on Datatables platform

After successfully integrating the datatables on my VF page, I now have one final requirement: to display any negative values in red and bold within numerical columns. In my Salesforce implementation, I am using <apex:datatable> for my table. Each nu ...

Tips for locating a webpage element with Selenium?

click here for image driver=webdriver.Chrome() driver.get("https://compass.tinkoff.ru/") driver.maximize_window() driver.implicitly_wait(20) elem = driver.find_element(By.XPATH, '//button[text()="Open Full Map"]').click() tim ...

Ensure that the sidebar automatically scrolls to the bottom once the main content has reached the bottom

I am facing an issue with a sticky sidebar that has a fixed height of calc(100vh-90px) and the main content. The sidebar contains dynamic content, which may exceed its defined height, resulting in a scrollbar. On the other hand, the main content is lengthy ...

Rearrange the position of the default app name on the navigation bar

I have developed a MVC5 application and by default, the nav-bar displays the "application name", "home", "contact", etc. The application name is positioned on the left side of the screen, but I would like to move it to the center. How can I achieve that? ...

An effective method for modifying the active class on an li element in jQuery and ensuring that the user is directed to the desired page upon clicking the li element

I am facing an issue with my script tag. When I click on the links test.php or test2.php, the active class changes from index.php to the respective file but I am not redirected to the clicked page. I have tried solutions from various sources but none of th ...

What are the steps to stop the left alignment of header text?

As I'm working on designing a unique Markdown theme in CSS, I am currently facing some challenges with regards to the styling of headers. Specifically, the h1 header is styled as follows: h1 { border-top: 1px solid black; width: 10%; margin: 0 ...

Access an HTML element and using JavaScript to make changes to it

As a new web developer, I am eager to create a grid of file upload zones on my site. I have decided to use DropZone.js for this project. I have customized DropZone and added multiple drop zones in the HTML. The grid layout consists of four rows with four ...

Retrieve JSON data from Form Submission

While I am not a front end developer, I have been trying my hand at it recently. I hope that the community here can assist me with an issue I am facing. I have a form that is supposed to send files to a server-side API like shown below: <form id="uploa ...

The anchor for the circular image is oversized

Currently, I have a PHP code that displays a user's profile picture, and when clicked, it takes them to their own profile. The image is displayed correctly, and the link works fine. However, there seems to be an issue with the area covered by the anch ...

Combining broken down values within a loop

https://i.sstatic.net/PI3NI.png Take a look at this image, then review the code I've provided: function addNumbers() { var inputList = document.getElementById("listInput").value.split(" "); for(i = 0; i <= inputList.length; i+=1) { ...

Is there a way to monitor the home button press event within a PhoneGap application?

Hello! I'm curious if there is a way to track when the Home button is pressed on both Android and IOS using phonegap phonegap build. I have looked into events for the home button press, but have only found information on back button events so far. ...

Looking for a smart way to extract all the selected elements from a form?

I am attempting to retrieve all the checked items from this form using JavaScript. I have looked at previous solutions, but none of them fit my requirements. <form id="checkform" class="container" style="margin-top:20px;"> <input type="checkb ...

What could have caused this issue to appear when I tried running ng build --prod?

Issue encountered while trying to build the ng2-pdf-viewer module: An error occurred in the webpack loader (from @angular-devkit/build-optimizer) with the message: TypeError: Cannot read property 'kind' of undefined. This error is related to A ...

How can I position two bootstrap tables side by side based on their columns

Currently, I am utilizing bootstrap and Laravel form control to generate the table structures below. The one issue I am encountering is figuring out how to align the delete and edit buttons from two separate tables. Here is a snapshot of the current layout ...

Is there a faster method for adding and removing classes on a table?

I have a sizeable table containing 27 columns and anywhere from 5 to 100 rows. To switch between a simple view showing the first 5 columns and an expert view showing all 27 columns, I have implemented a mode switch (checkbox). Currently, I am using the fo ...

What is the best way to incorporate an exception for the printThis() element?

Is there a way to exclude a specific div from being printed when using the printThis() function? For example: <div id="print-it"> <div>hello</div> <div id="no-print-this"> <button>must be show on page but not print</but ...

Dropdown selection triggers an Ajax request

I have encountered an issue while attempting to make an Ajax request to the page chosen in a drop-down menu. While most of my script code works fine in binding a mouse click to table rows, it seems to fail in this particular scenario. The error message I r ...

How can you gradually make a CSS border disappear?

Can an element's border fade away with the use of JavaScript only, without relying on jQuery for animation? We are currently working with Sencha and it seems that ExtJS only allows for animating element size and position. While CSS3 offers helpful ani ...

JavaScript for controlling first-person movement with a mouse

Currently, I am working on implementing a first person movement feature using the mouse. While I have successfully implemented it using the keyboard, I am facing challenges with the mouse input. The issue arises from the ambiguity in movement directions ca ...