Creating an unconventional sleek edge using CSS

By mistake, I accidentally created this unique border for an image that I surprisingly find quite appealing.

Take a look at the code snippet below.

The results are truly stunning!

.smoothed {
      height: 140px !important;
        /* background: red; */
      border-radius: 50%;
      padding: 10px 3px 38px 1px;
}
html, body { background-color: black; color: white; font-family: sans-serif; }
<p>INCREDIBLE OUTCOME</p>
<img src="https://i.pinimg.com/236x/53/f7/45/53f745aad228c9eddb1adc8bd212cca1.jpg" class="smoothed">

<p>NOT SO GOOD RESULT</p>
<img src="https://as2.ftcdn.net/v2/jpg/00/53/72/03/1000_F_53720345_h0zZ8cKmJZyPoKTnn2bsjArj00zn49hc.jpg" class="smoothed">

However, the issue lies in its compatibility only with square images.

I also face challenges when trying to place it within a p paragraph or another tag like <h1>, maintaining the same size as the text (specifically pertaining to height).

Could someone assist me in refining the result to ensure it works for all images of any size and can be encapsulated within a tag such as <h1>, effectively displaying the image in a circular form? Feel free to utilize different tags to wrap the img before placing it in h1; the key is functionality.

Answer №1

These resources may provide assistance.

Possible solution :

.smoothed {
      height: 140px !important;
      aspect-ratio:1;
        /* background: red; */
      border-radius: 50%;
      padding: 10px 3px 38px 1px;
      object-fit:cover;
      object-position: top center;
}
html, body { background-color: black; color: white; font-family: sans-serif; }
<p>GOOD RESULT</p>
<img src="https://i.pinimg.com/236x/53/f7/45/53f745aad228c9eddb1adc8bd212cca1.jpg" class="smoothed">

<p><del>BAD</del> RESULT</p>
<img src="https://as2.ftcdn.net/v2/jpg/00/53/72/03/1000_F_53720345_h0zZ8cKmJZyPoKTnn2bsjArj00zn49hc.jpg" class="smoothed">

If circles are not appearing, check the default values of padding and border-box

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

Troubleshooting Website Navigation Bar and Layout with HTML, CSS, and Bootstrap5

I am facing a challenge with navbar positioning. My navbar items are missing after adding the image below. I have attempted to adjust the element positions but to no avail :( I also tried to create a fixed-top navbar, but it didn't work either :( I ...

Issue with Bootstrap 4 toggle button functionality - looking for a fix

I'm encountering an issue with my website where the toggle button for the navbar is not functioning properly after I added it. Below is the code snippet for my navbar: <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class=" ...

What is preventing me from being able to reposition certain tables on my site?

I have successfully implemented certain aspects of my responsive website, but I am encountering some difficulties in moving specific tables. I can adjust the table in various directions, except for moving it downwards. Even when adding the word !important ...

Utilizing Angular's ng-if to dynamically adjust Twitter Bootstrap's column size with col

Here is the code snippet: left block right block This code displays the left block on the left side of the screen and the right block on the right side, adjusting for different screen sizes. If the screen i ...

Animating Elements with CSS and HTML

Struggling with my website project, specifically creating a login page. The issue arises when resizing the browser, causing elements to look misaligned and chaotic. Before: view image here After: view image here /* Bordered form */ form { margin-l ...

Proper implementation of the HTML5 <hr> element

Currently working on a fresh webpage design for a company, keeping in mind the sensible guidelines of HTML5/W3C. After delving into the semantic significance of <hr />, I find myself pondering its suitable usage: <section name="historyItem"> ...

Styling a Fixed Header in CSS/HTML - Scroll Effect

Is it possible to hide only the upper part of the nav-bar, similar to the behavior in WhatsApp? I am using material-ui for this particular use-case. Currently, my implementation causes the app-bar to extend only when the scroll position is less than 48px, ...

Ensure that the responsive SVG image remains centered even when resizing

I have been attempting to center crop the responsive SVG image while resizing. Even though I used preserveAspectRatio="xMidYMax slice", the image width does not stay consistent with my screen size. body{ margin:0;padding:0; } .wrapper { position: re ...

Customizing the appearance of default UI elements in asp.net

Recently, I was tasked with creating an image uploading function for a web application using asp.net. To start off, I utilized the standard input asp.net button along with the browse and filename label. The implementation of this code is quite straightforw ...

How can I eliminate the space between the navbar and toggle menu item in Bootstrap 4?

Upon experimenting with Bootstrap 4, I came across the default navbar template. While using it for learning purposes, I encountered difficulties when trying to modify or style the CSS. I'm having trouble understanding why there is a gap between the na ...

With the simple click of a button, I aim to refresh and enhance the appearance of a polygon

My goal is to create a button that, when clicked, causes the gray stripe in the middle to transition to the right. I am not very familiar with HTML, CSS, and JavaScript so I could use some help figuring out how to achieve this effect. Here is a quick illus ...

Create a customized menu with jQuery that disappears when hovered over

Check out this menu I've created: http://jsbin.com/useqa4/3 The hover effect seems to be working fine, but I'm looking to hide the div #submenuSolutions when the user's cursor is not on the "Solution" item or the submenu. Is there a way to ...

The issue with certain <select> elements not showing the global ng-options

In my HTML code, I call the select element like this: <form class="form-inline col-sm-6" ng-repeat="critere in criteres | orderBy:'data'"> <div class="form-group"> <label class="control-label">{{critere.lib}}</label> ...

Trouble encountered when attempting to programmatically dismiss a modal following a confirmation alert

When the user clicks on the close button, I want to display a confirmation alert to confirm if they really want to close the modal. However, I have encountered an issue with hiding the modal and preventing it from being hidden in the two solutions that I h ...

What is the best way to obtain a date in the format of yyyy_mm_dd from a datepicker tool?

I am working with 2 datepickers that have similar structures, but different names. The first one has the id "fecha_1_1" and the second one has the id "fecha_1_2". <div class="col-sm-3"> <p>Desde</p> <div class="f ...

Show/hide functionality for 3 input fields based on radio button selection

I need assistance with a form that involves 2 radio buttons. When one radio button is selected, I want to display 3 text boxes and hide them when the other radio button is chosen. Below is the code snippet: These are the 2 radio buttons: <input type= ...

The pull-right function doesn't seem to function properly when applied to a button within a Bootstrap alert

Within my Bootstrap alert, I have a text and an undo button displayed. However, the button is not aligned correctly to the right, causing a misalignment with the close button on the right and the text on the left. I attempted to resolve this issue using th ...

children blocking clicks on their parents' divs

I previously asked a question about a parent div not responding to click events because its children were blocking it. Unfortunately, I couldn't recreate the issue without sharing a lot of code, which I didn't want to do. However, since I am stil ...

Using bootstrap-vue sticky columns without specifying a column variant is easier than you think

Let's cut to the chase with an example I created using bootstrap-vue's documentation to help clarify the issue: <template> <div> <div class="mb-2"> <b-form-checkbox v-model="stickyHeader" inline>Sticky header& ...

What is the best way to use res.send() to target a specific ID within an HTML tag in Node.js?

In my search.html file, I have the following form: <form class="myform" action="/classi" autocomplete="on"> <input type="text" name="search" > <button type="submit" ></button> Upon pressing the button, the following code in ind ...