Dividing the z-index by half of the shape

I am trying to achieve the following shape:

https://i.stack.imgur.com/Lr9gv.png

So far, I have attempted the following code. How can I combine these elements together?

.clal-loader{
  display:flex;
}
.clal-loader div{
  border: 10px solid #38477e;
  border-left: 0;
  border-bottom-right-radius: 100px;
  border-top-right-radius: 100px;
  width: 30px;
  height: 30px;
}
.clal-loader div:nth-child(1){
   border-color:#0cabec;
}

.clal-loader div:nth-child(2){
 transform: rotate(-180deg);
     position: absolute;
    left: 25px;
    z-index: -1;
}
<div class="clal-loader">
  <div></div>
  <div></div>
</div>

Answer №1

Using radial-gradient and a single element, you can create a unique shape by combining four similar gradient styles to form a quarter circle design:

.box {
  width:100px;
  height:150px;
  background:
    radial-gradient(circle at bottom left, transparent 40%,blue  40%, blue  60%,transparent 61%) top,  
    radial-gradient(circle at bottom right,transparent 40%,green 40%, green 60%,transparent 61%) top,
    radial-gradient(circle at top right,   transparent 40%,green 40%, green 60%,transparent 61%) bottom,
    radial-gradient(circle at top left,    transparent 40%,blue  40%, blue  60%,transparent 61%) bottom;
    
  background-size:100% 50%;
  background-repeat:no-repeat;  
}
<div class="box">

</div>

To achieve a similar effect with two elements, utilize pseudo-elements within each div and adjust the z-index for proper layering:

.box {
  width:100px;
  height:100px;
  position:relative;
}
.box > div {
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
}
.box > div:before,
.box > div:after {
  content:"";
  position:absolute;
  width:70%;
  height:50%;
}

.box > div:first-child {
  color:red;
}

.box > div:last-child {
  color:blue;
}

.box > div:first-child::before {
  z-index:1;
  top:0;
  left:0;
  border-top:15px solid;
  border-right:15px solid;
  border-top-right-radius:100%;
}
.box > div:first-child::after {
  bottom:0;
  left:0;
  border-bottom:15px solid;
  border-right:15px solid;
  border-bottom-right-radius:100%;
}
.box > div:last-child::before {
  top:0;
  right:0;
  border-top:15px solid;
  border-left:15px solid;
  border-top-left-radius:100%;
}
.box > div:last-child::after {
  bottom:0;
  right:0;
  border-bottom:15px solid;
  border-left:15px solid;
  border-bottom-left-radius:100%;
}

*,*::before,*::after {
  box-sizing:border-box;
}
<div class="box">
  <div></div>
  <div></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

A new URL must be refreshed for the link to properly bind the data received from the API call with the subscribe method

In my Angular application, I have a URL link that fetches data from the backend API using the subscribe method in a component. The expected behavior is that when this URL is accessed in a browser, the data should be displayed in the corresponding HTML comp ...

Revamping Slideshows: Bringing CSS Animation to JavaScript

/* JavaScript */ var slides=0; var array=new Array('background.jpg','banner.jpg','image.jpg'); var length=array.length-1; $(document).ready( function(){ setInterval(function(){ slides++; ...

Formatting text and images in CSS

Looking to align images at the bottom of each column in a div with 3 columns, but struggling due to varying text lengths. Any tips on how to achieve this? Thank you, Carolin #content_row{ margin-top:150px; margin-left:10px; margin-right:10 ...

Ways to create a downward expanding navigation menu when collapsed

Trying to accomplish the following, please refer to the image below. I am looking to have the yellow bar extend down when the collapsed menu is open. Currently, the navigation links are hidden behind the logo as shown in the second image below. Is there a ...

Creating an external JavaScript and CSS file for date picker in Eclipse can be done by following a few simple steps. By creating separate files for the

I am using the following javascript and css styles: <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jq ...

What causes an image background to take precedence over the background color of Bootstrap buttons?

Why is the CSS overriding the bootstrap button background styling and making it transparent instead of the default color? For example, if I have a button with the following styling in my document that sets the background-image of the entire body to an ima ...

Having trouble with Angular2's Maximum Call Stack Exceeded error when trying to display images?

I am facing an issue in my Angular2 application where I am trying to display an image in Uint8Array format. The problem arises when the image size exceeds ~300Kb, resulting in a 'Maximum Call Stack Exceeded' error. Currently, I have been able to ...

Using jQuery, you can easily insert a <span> tag around selected text and then save this modification permanently in a local HTML file

I have compiled notes in an HTML file stored on my local computer, with the intention of keeping it solely for personal use. For instance, I have a snippet like this: <p> this is an example text</p> My goal is to highlight the word "example" ...

Issue encountered when attempting to select a button with selenium

I'm attempting to use Selenium to click on a button, but encountering an error in the process. The specific error message is shown below: https://i.stack.imgur.com/NQjnh.png This snippet of code represents the accessed HTML page: https://i.stack.i ...

Data binding functions properly only when utilizing the syntax within the select ng-options

In the book AngularJS in Action, I came across this Angular controller: angular.module('Angello.Storyboard') .controller('StoryboardCtrl', function() { var storyboard = this; storyboard.currentStory = null; ...

Ways to determine if a date matches today's date within a component template

I am currently displaying a list of news articles on the webpage and I want to show the word "Today" if the news article's date is equal to today's date. Otherwise, I want to display the full date on the page. Is there a way to compare the news.D ...

The event is being triggered on two separate occasions

Hey there! I'm trying to bind the onclick event to both a parent and child element using the same method. However, I'm running into an issue where the event is being fired twice. Any suggestions on how to prevent this from happening? <div id= ...

Best way to eliminate empty options from dropdown and ensure that required validation is functioning in AngularJS?

My dropdown is populated with owners from the owners data, but it includes an extra blank option. I need to eliminate this blank option. However, when I make the necessary changes to remove it, the required validator stops working properly. <md-input-c ...

The Art of Repeating: Navigating through a Multi-Layered Array

My PHP Array looks like this: $fruits = array( array("Apple", 1.25), array("Banana", 0.86), ); Desired HTML Output: I want the HTML output to be formatted as follows: Fruit: Apple Price: 1.25 Fruit: Banana Price: 0.86 Attempts Made: I tried ...

Unable to achieve horizontal alignment with DIV element set as inline-block

Currently, I have five columns that are aligned using the display:inline-block. Everything seems to be working fine, but there's a peculiar issue that arises when I refresh the page multiple times. Occasionally, while the first column remains at the t ...

Exploring the Differences in Table Resizing between IE8, IE7, and Chrome when using table-layout:fixed

For my HTML timeline view, I encountered an issue that I'm hoping to resolve: I have a table row with 12 cells representing the 12 months, each with a colspan based on the number of days in that month. Another row in the same table contains the indiv ...

Animation Effects in Opera and Internet Explorer

Just unveiled my latest project, CSSload.net - an awesome tool for generating CSS spinners and bars. The animations are running smoothly on Firefox and Webkit browsers. Curious if anyone has tips on animating elements like this in Opera and IE? ...

Best practices for sending variables to an HTML page using nodemailer

I am interested in sending an email with an HTML template that includes dynamic data. For example, I want to include a unique id within a link on the page. Is it possible to insert dynamic data into HTML content when sending emails? If yes, I would apprec ...

The command response.setHeader("Refresh", "0") failed to execute

My webpage needs to be refreshed when the user session has expired or the connection is not active. Despite trying various codes, I have been unsuccessful in achieving this. The last code snippet that I implemented is as follows: if(session.getAttribute(" ...

Center a span vertically inside a div as the text within the span grows to occupy the entire div

I am facing an issue with a table that has 25 td's. Each td contains specific elements as shown below: <td> <div> <span> text </span> </div> </td> Additionally, there is a script in place that adj ...