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

Using VBA to Populate Dropdown List on Webpage from an iFrame

I am facing an issue with my code that aims to interact with a webpage by clicking on a link and then modifying dropdown lists within an Iframe. Specifically, I am attempting to populate the Manufr dropdown list based on data from the Year iFrame using VBA ...

Ways to make Joomla! send emails in HTML format

I am knowledgeable about using Joomla! with phpMailer for sending emails. I understand that in order to send emails in HTML format, the following code must be used: $mailer->isHTML(true); However, this approach requires editing the source code of defa ...

What steps should I follow to create a basic file upload page on my server?

Recently, I've been on a quest to create a straightforward file upload page that allows me to easily send files to my server. The concept is for the site to have a feature where I can simply upload a file and have it stored in a specific folder on the ...

Obtaining the value of an item in an unordered list

Hi everyone, I have been trying to extract the value of <li> elements that display images horizontally. Below is the HTML code I am working with: <div id="layoutInnerOptions"> <ul id="navigationItemsContainer" class="layouts_list"> <l ...

I require a modification in the style of every anchor element found within a div containing the designated class

In a div with the class fview, there is a nested element called iNside which contains a span. Additionally, there are anchor elements within another span, ul li, and another div, among others. I want all anchor elements to have the same style. I tried app ...

Replacing inline CSS with styled components in Next.js Sass modules

In order to display emoji icons in my Next.js App, I utilize the Twemoji library. These emojis are rendered as <span><img></span> elements in the final HTML output. To customize their default width and height, I use the !important rule in ...

Utilizing Images as Backgrounds in JSP

Looking for assistance with adding a background image in a JSP file without overlapping the navigation bar? Check out my code below: <jsp:include page="index_header.jsp"></jsp:include> <div class="container"> <div style=&ap ...

How come only the individual top, bottom, left and right paddings function correctly while the combined padding does not respond?

Seeking to customize a button using SCSS file that is connected to HTML. This button is part of a flex layout design. The element's size is set at 83.333×16px. The box-sizing property is defined as: box-sizing: border-box; Adding padding with s ...

The Javascript navigation bar is not displaying properly on mobile devices as it should

After customizing the responsive navbar tutorial from W3Schools using CSS and JS, I encountered an issue. I wanted to include a logo and a web page title before the navbar, which worked perfectly when the webpage was maximized. However, when I resized the ...

What causes my variable to show None instead of the current stock price?

I attempted to extract the stock price data from using BeautifulSoup. However, my program is not displaying the stock price and instead showing "None". How can I correctly retrieve the stock price information? My provided code snippet: from bs4 import Bea ...

How can I customize the appearance of the arrow in a Material UI tooltip?

Looking to enhance the appearance of a Material UI tooltip arrow with custom styling, but struggling to set the border and background colors. Here's the current configuration in React: const useStylesBootstrap = makeStyles(theme => ({ arrow: { ...

Display loader until the document body has finished loading

Many developers have shared solutions for displaying a loader while an element is being loaded. However, my challenge is unique. I want to display a loader before the document body is fully loaded. The issue arises from an AJAX call in my code: var url = ...

Working with HTML5 canvas to draw multiple images

Here is the code I'm working with: http://jsfiddle.net/zyR9K/4/ var Enemies = { x: 25, y: 25, width: 20, height: 30, speed: 0.5, color: "#000", draw: function () { canvas.fillStyle = ...

When using CSS float:left and overflow:visible, the text may get cropped-off at

I'm currently experimenting with creating a color gradient in javascript using numerical values within some of the divs to indicate scale. However, I've run into an issue where as the values get larger, they are cut off due to the float:left prop ...

The 'utf-8' codec is unable to interpret the byte 0x96 at position 227, as it is an invalid start byte

Recently, I began working with Django. Unfortunately, I encountered an error that I haven't been able to solve. Can anyone explain why this error is occurring? Specifically, I am utilizing {% extends "base.html" %} on my login page. Here is the exa ...

Expanding the full width of the bootstrap navbar

Let's cut to the chase - I'm working with Bootstrap 4 and trying to make my navbar fill the entire width (excluding margins). I know this question has been asked before, so I checked out a post here which suggested using the .nav-fill class, but ...

Populating Modal on open with jquery/javascript

I am trying to dynamically populate a Modal when it opens, but so far all my attempts using append have failed. Here is the code for my Modal: <div class="modal fade" id="ModalForAllUsers" tabindex="-1" role="dialog" aria-hidden="true"> <div ...

Should a tabindex attribute be added to an input field with type="reset"?

Would adding a tabindex attribute to an input[type="reset"] serve any accessibility or semantic purpose? Or would it be better to avoid it to prevent forms from being inadvertently and frequently reset? ...

Accessing the parent element within a hover declaration without explicitly naming it

I am facing a challenge with three nested divs, where I want to change the color of the children when the parent is hovered. However, I prefer not to assign a specific class name to the parent element. The issue arises because the children have their own ...

Insects featuring a button and tooltip duo creating a captivating "pull-effect"

Why is the button pulling when I move the cursor over a camera? Is there a way to solve this issue? <div class="input-group-btn advanced-group"> <button class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Send Imag ...