Break apart animation similar to the 🎊 emoji using CSS styling

I am attempting to create an animation of a circle splitting open on two sides, similar to the 🎊 emoji flipped upside down. I have positioned two half-circle elements next to each other. However, my attempts to animate one side are not producing the desired effect - I want the split to pivot at the bottom of the semi-circle rather than in the middle. When I rotate one of the halves, they end up overlapping due to their proximity, and I have yet to find a solution for this issue (I considered moving one to the left or right during the animation, but I'm unsure...).

  .circlecontainer {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .halfright {
    width: 150px;
    height: 300px;
    border-top-right-radius: 150px;
    border-bottom-right-radius: 150px;
    background: orange;
  }

  .halfleft {
    width: 150px;
    height: 300px;
    border-top-left-radius: 150px;
    border-bottom-left-radius: 150px;
    background: orange;
    animation: splitleft 3s;
  }
  
  @keyframes splitleft {
    0% {
        transform: rotate(-0deg)
    }
    100% {
        transform: rotate(-90deg)
    }
  }
<div class="circlecontainer">
        <div class="halfleft"></div>
    <div class="halfright"></div>
  </div>

That's the current state of the project! I hope my explanation is clear enough as it can be quite tricky to describe...

Answer â„–1

If you need guidance on transform-origin, this snippet may be helpful:

.circlecontainer {
  display: flex;
  justify-content: center;
  align-items: center;
}

.halfright {
  width: 150px;
  height: 300px;
  border-top-right-radius: 150px;
  border-bottom-right-radius: 150px;
  background: orange;
  animation: splitright 3s;
  transform-origin: bottom left;
}

.halfleft {
  width: 150px;
  height: 300px;
  border-top-left-radius: 150px;
  border-bottom-left-radius: 150px;
  background: orange;
  animation: splitleft 3s;
  transform-origin: bottom right;
}

@keyframes splitleft {
  0% {
    transform: rotate(-0deg)
  }

  100% {
    transform: rotate(-90deg)
  }
}

@keyframes splitright {
  0% {
    transform: rotate(0deg)
  }

  100% {
    transform: rotate(90deg)
  }
}
<div class="circlecontainer">
  <div class="halfleft"></div>
  <div class="halfright"></div>
</div>

Answer â„–2

Whenever using transforms, the default pivot point will be at the center of the div. However, if you need to pivot from where two circles meet at the bottom, you can achieve this by utilizing the transform-origin property:

  .circlecontainer {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .halfright {
    width: 150px;
    height: 300px;
    border-top-right-radius: 150px;
    border-bottom-right-radius: 150px;
    background: orange;
    transform-origin: bottom left; /* THIS ONE!! */
    animation: splitright 3s forwards;
  }

  .halfleft {
    width: 150px;
    height: 300px;
    border-top-left-radius: 150px;
    border-bottom-left-radius: 150px;
    background: orange;
    transform-origin: bottom right; /* THIS ONE!! */
    animation: splitleft 3s forwards;
  }
  
  @keyframes splitleft {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(-90deg);
    }
  }
  
    @keyframes splitright {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(90deg);
    }
  }
<div class="circlecontainer">
    <div class="halfleft"></div>
    <div class="halfright"></div>
</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

What is the best way to navigate between different areas of an image using html and javascript?

I am currently in the process of learning how to develop mobile applications, and I am still in the early stages. Although this question is not directly related to mobile development, it pertains more to html/css/js. My goal is to create a simple game wh ...

What could be causing my CSS code to not function properly within Vue.js?

Having trouble with css in VueJs. I can't seem to figure out what I'm doing wrong. Generally, my scoped style css works fine in vuejs, I can target ids and classes without any issues. The problem arises when trying to change the internal css va ...

Angular 8: Implementing Form Validation with a Boolean Flag

Within my HTML code, I have a function (change)="limitUser($event)". In Typescript, I utilize a for loop to iterate through each element and determine if the value is less than 10. If it exceeds 10, the inValid = true condition is set. All form fields in m ...

Ways to streamline repetitive CSS rules within media queries

As I work on defining multiple media queries, I realize there is some redundant code within them: @media only screen and (max-width:768px), only screen and (min-width:769px) and (max-width:1040px) { .list__figure { margin-right: 20px; ...

``motioning a component beneath another component that may be in a state

Having an issue with my CSS. I have some elements generated by JavaScript and when hovering over them, another element is displayed below the others for some reason. Here's the CSS related to this problem: .hiddenTextjob { display:none; ...

Scrolling to the active list item in the navigation bar

Having an unordered list with the id mainul in the navigation bar is causing a problem when the page reloads. The navigation bar always starts at the beginning, but I would like it to automatically scroll to the active li element. This is my HTML code: & ...

Identify the row containing a value of null using jQuery (functionality not performing as anticipated)

Whenever the user clicks on the GetData button, I retrieve JSON data and display it in an HTML table similar to the demo below. Demo: https://plnkr.co/edit/I4XYY6CZohf7IS6wP8dR?p=preview There are instances where the value can be null, such as the loanNu ...

Dual-Language Dublin Core Metadata for Document Description

If I want to express the document title in two languages using Dublin Core, how can I do it? Based on my research, I could do the following: <meta name="dc.language" content="en"> <meta name="dc.language" content="fr"> <meta name="dc.title ...

Ionic directive ng-disabled not functioning as expected

Upon running the Ionic application, I noticed that the radio button is not being disabled even with the use of ng-hide.<input type="radio" ng-disabled="true"> ...

Setting up a textarea tooltip using highlighter.js

I'm experimenting with using highlighter.js within a textarea. I've customized their sample by substituting the p with a textarea enclosed in a pre tag (for right-to-left language settings). <div class="article" style="width: 80%; height: 80% ...

javascript the unseen element becomes visible upon page loading

my website has the following HTML snippet: function getURLParameters() { var parameters = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { parameters[key] = value; }); return param ...

How to adjust the vertical spacing between divs in a 960 grid using CSS?

I'm currently experimenting with the 960 grid css framework. How can I eliminate the space between two divs stacked on top of each other? [referring to the gap between the blue lines in the image] I created my CSS using the CSS generator found at . ...

Add a CSS class to the text that is selected within a Content Editable div

Hey there, I'm having an issue where the class is being applied to the button when pressed instead of the selected text. Here's my current code: The button needs to be a div, but it might be causing the problem. I just want the highlighted text ...

Distinguishing between these two hover text types: JQuery CSS, what sets them apart?

As a total jQuery novice, I've been curious about the difference between these two types of text that appear when you hover over something. Can someone please clarify what each one is? Thank you very much. First hover text: When hovering over the up- ...

Tips on ensuring the first column of an HTML table remains fixed in responsive design

I am trying to create a responsive HTML table where the first column remains fixed. I have a select box on my PHP page and I am using AJAX to display data from a database in the HTML table. However, when selecting a value in the select box in a responsiv ...

Utilizing the power of JavaScript in an HTML file to develop a straightforward price calculator

I am new to the world of HTML coding and currently working on an assignment for my online computer course. I reached out to my professor for help, but unfortunately, he hasn't been very responsive. The task at hand is to create a basic cost calculator ...

The ng-route feature seems to be malfunctioning and I am unable to identify the error, as no information is being displayed in the console

Here is the code in my boot.php file where I have set up the links <ul class="nav nav-pills nav-stacked"> <li role="presentation"><a href="#/valley">Valley</a></li> <li role="presentation"><a href="#/beach"> ...

Creating a dynamic image slider that smoothly glides across a webpage

I've been working on a carousel (image slider) for my website and I need some help. Specifically, I want to reposition the entire slider slightly to the left on the webpage. You can see the slider in action on this site: and I also created a jsfiddle ...

Sharing information linked to dynamically generated HTML elements in MVC5

Currently, I am working on developing an MVC5 application. Within a view, I am dynamically creating HTML elements such as textboxes and dropdown lists using a JSON result returned from the server and jQuery. Now, my goal is to submit the selected data IDs ...

Polyfill for the :nth-column CSS4 Grid-Structural pseudo-class

In my CSS grid layout, I want to include a margin in every even column. While the :nth-column pseudo-class would be ideal for this, it unfortunately won't be supported in the near future. Could anyone recommend any polyfills that I could utilize, or ...