Design a droplet-shaped CSS element with a static background image and no rotation

Can anyone help me create a unique CSS shape with a background image? I have provided the code for the shape below:

.figure{
    width: 180px;
    height: 180px;
    border: 1px solid #32557f;
    border-radius: 0 50% 0% 50%;
    transform: rotate(45deg);
    bottom: -50px;
    position: relative;
    left: 17px
  }
<div class="figure"></div>

When I add a background image, it is affected by the rotation. Here is the updated code:

.figure{
    width: 180px;
    height: 180px;
    border: 1px solid #32557f;
    border-radius: 0 50% 0% 50%;
    transform: rotate(45deg);
    background-size: 100%;
    background-image:url('https://images.unsplash.com/photo-1593642634315-48f5414c3ad9');
    background-repeat:no-repeat;
    bottom: -50px;
    position: relative;
    left: 17px
  }
<div class="figure"></div>


I have come up with a solution that looks like this:

  .figure {
    width: 180px;
    height: 180px;
    border: 1px solid #32557f;
    border-radius: 0 50% 0% 50%;
    transform: rotate(45deg);
    bottom: -50px;
    position: relative;
    left: 17px;
    overflow: hidden;
  }
  

  .test{
    background-image: url(https://images.unsplash.com/photo-1602000750546-f8e331a082d1);
    transform: rotate(-45deg);
    height: 145%;
    width: 142%;
    background-size: cover;
    background-repeat: no-repeat;
    background-size: 100%;
    position: fixed;
    top: -43px;
    right: -44px;
  }
<div class="figure">
    <div class="test"></div>
</div>

Does anybody know what this CSS shape is called?

Thank you!

Answer №1

If you want to avoid using background-image and adjust the rotation, try utilizing an img element along with transform: rotate(-45deg):

.figure {
  width: 180px;
  height: 180px;
  border: 1px solid #32557f;
  border-radius: 0 50% 0% 50%;
  transform: rotate(45deg);
  bottom: -50px;
  position: relative;
  left: 17px;
  overflow: hidden;
}

img {
  height: 142%;
  transform: rotate(-45deg) translateY(-39%);
}
<div class="figure">
  <img src="https://images.unsplash.com/photo-1593642634315-48f5414c3ad9" />
</div>


Alternatively, you can opt for a different approach by utilizing clip-path along with an svg:

img {
  height: 260px;
  clip-path: url(#teardrop);
}
<img src="https://images.unsplash.com/photo-1593642634315-48f5414c3ad9" />

<svg>
    <clipPath id="teardrop">
        <path
            d="M88.49 0C121.05 32.57 141.41 52.92 149.55 61.06C186.12 97.63 186.12 156.93 149.55 193.5C141.41 201.64 121.05 221.99 88.49 254.56C55.92 221.99 35.57 201.64 27.43 193.5C-9.14 156.93 -9.14 97.63 27.43 61.06C35.57 52.92 55.92 32.57 88.49 0Z"
        ></path>
    </clipPath>
</svg>

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

Approaches to designing a reusuable Polymer component

As I start diving into the realm of Polymer web components, I am faced with the challenge of designing a product that can seamlessly integrate into multiple client applications or operate as a standalone application. This product happens to be a game with ...

The scroll function remains unchanged when using overflow-y scroll and border radius

I need help with styling a div that will contain a large amount of text on my webpage. I want to use the overflow-y property for scroll, but the issue arises when trying to style the scroll bar with a radius. Check out this jsfiddle link for reference: ht ...

extracting metadata from HTML files with Java

Hello! I have been working on a project that requires metadata for different file types such as HTML and XML. Are there any APIs available to help with this task? Any ideas or suggestions regarding the matter would be greatly appreciated. Thank you in ad ...

What is the best way to retrieve the updated window dimensions following a rotation of an iPad screen?

I need to update the size of a specific element on a webpage based on screen rotation, especially for iPads and all other mobile devices. The new dimensions should be calculated according to the updated screen size. While attempting to implement this, I e ...

Incorporating a switch button for toggling functionality in a Rails application

I attempted to convert a select tag into a JavaScript toggle on/off switch within my Rails application. After some searching, I came across a straightforward solution on the W3Schools website. http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryj ...

Finding a solution to this issue in Angular will consistently result in a false outcome

Can anyone explain why I keep getting the error message "This condition will always return 'false' since the types 'typeof ChartType' and 'ChartType' have no overlap" whenever I try to compare charTypeEnum with ChartType.text? ...

What is required to create a basic application that can function offline while featuring an HTML/CSS user interface?

Newbie inquiry: I am interested in creating a small application that can run offline on a desktop computer. The amount of data to be saved is minimal, so I have the option to use a file or some type of database. However, my main question is: What languag ...

The $mdSticky feature in AngularJS Material seems to be malfunctioning

It's been a challenge for me to get the md-toolbar to stay in the top position. I decided to create a custom directive using the $mdSticky service in AngularJS. var app=angular.module('app',['ngMaterial']); app.controller(&apos ...

Modify Vuetify's border autocomplete styling

Currently, I have vuetify 1.5.x set up on my codepen. Upon reviewing my codepen, I noticed that the line displayed on the autocomplete feature appears to be quite thick. My goal is to have that line be only 1px. For the select field (outline border), I int ...

Seeking assistance in understanding how to validate images in Javascript code with the use of Selenium WebDriver. Any t

I am looking to implement the following code to verify if the images on the webpage have loaded successfully. Would anyone be able to clarify how this javascript code actually confirms whether the images are loaded or not? ArrayList<WebElement> imgE ...

Attempting to remove options in a Multiple Choice scenario by selecting the X icon beside each one

I'm working on a multiple choice quiz and I'd like to add a button or icon resembling X in front of each option (even in front of the radio button), so that when I click on it, only that specific option is deleted. How can I achieve this? For in ...

Is it possible to change a Material UI style without resorting to an HOC?

Is there any method to modify the styling of a Material UI component without the need to create an entirely new component using withStyles()? For example, if I am currently displaying the following and simply want to adjust the color of the "Delete" label ...

What could be the reason for my PHP files not appearing in my CSS navigation tabs?

In my PHP document, I am using CSS navigation tabs to display three different files. <div id="Tum" class="w3-container training"> <h2>TUM</h2> <?php include("tum.php"); ?> </div> <div id="Atol" class="w3-container traini ...

Unable to adjust the width of a table column within a horizontally scrollable container

I am struggling to resize the columns of a large table with 20 headers. Despite trying to place the table inside a div with overflow:auto, I still cannot achieve horizontal scrolling or make the div expand when resizing the columns. A sample code snippet ...

What is preventing the code from concealing the html div when the winOrNot function is given the argument (false)?

Can you identify why the "Congratulations" message in the div is not being hidden when the function is called with the (false) argument? <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div id= ...

Centering spans and divs is proving to be a challenge, as well as getting the margin-top and margin-bottom properties to function properly

I encounter this issue frequently, where my usual methods for centering objects do not seem to work. I am in search of a universal way to accomplish this task: <div> <span>content</span> <span> content</span> < ...

What happens to CSS specificity when JavaScript is used to change CSS styles?

When JavaScript modifies CSS, what is the specificity of the applied styles? For example: document.getElementById("demo").style.color = "red"; Would this be deemed as inline styling? ...

Implementing jQuery during the navigation between Node routes

Below is a snippet of my jQuery code: $(function () { $('.mnav a').click(function () { el = $('.border'); el.addClass('blink'); el.one('webkitAnimationEnd oanimationend msAnimationEnd animatio ...

"Enhancing User Experience with Hover Effects in HTML using .common

I'm pretty new to coding and currently working on a Github repository. On the same page, I have 12 clickBoxes that each have a hover effect applied where a PNG appears upon hovering. However, I've run into an issue where either the hover effect w ...

The process of sending a POST parameter to a page in PHP and opening it

When attempting to open a page using PHP, such as: $html = file_get_contents('https://hammihan.com/search.php'); I encountered an issue where the page was being redirected to https://hammihan.com/users.php due to an empty input for name. To addr ...