What is the best way to make a stylish curved content divider using CSS?

Currently, I am in the process of developing a small web project and have come across an interesting detail that I would like to incorporate: a curved content divider. While most dividers are simply straight lines, this one has more of a unique shape. I have been considering different ways to implement it using CSS or possibly SVG, but I'm unsure of the best approach. Take a look at the image below for reference: The gray content on top aligns perfectly with the orange curve, while the white content underneath follows along the same curve. Is there a way to achieve this effect through CSS or SVG without relying on images?

Your assistance is greatly appreciated!

Answer №1

After working on CSS rounded corners, this is my best attempt so far... still improving!

.divider {
  width: 100%;
  height: 51vw;
  position: relative;
  overflow: hidden;
  background: #fff;
}
.divider:after,
.divider:before,
.divider b:after,
.divider b:before {
  content: "";
  display: block;
  position: absolute;
}
.divider:after {  
  width: 63.7%;
  height: 62.5%;
  border-radius: 50% 50% 0 0/50%;
  bottom: -4px;
  left: -7.5%;
  border: red 2px solid;
  border-right: transparent 2px solid;
}
.divider:before {  
  width: 63.6%;
  height: 63.7%;
  border-radius: 0 0 50% 50%/50%;
  right: -7.5%;
  top: -4px;  
  background: #eee;
}
.divider b {
  display: block;
  width: 50%;
  height: 100%;
  background: #eee;
}
.divider b:after {
  width: 63.7%;
  height: 62.5%;
  border-radius: 0 0 50% 50%/50%;
  right: -7.5%;
  top: -4px;  
  border: red 2px solid;
  border-left: transparent 2px solid;
}
.divider b:before { 
  width: 63.6%;
  height: 63.7%;
  border-radius: 50% 50% 0 0/50%;
  bottom: -4px;
  left: -7.5%;
  background: #fff;
}
<div class="divider"><b></b></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

When using the each() function, the array shows a length of zero and does not

Although I am well-versed in PHP, my understanding of JQuery is lacking and I'm experiencing some difficulty with arrays. Despite researching numerous forum posts on the topic, I still can't seem to get it right. I believe I have an array struct ...

Utilizing jQuery/AJAX to transfer information to Morris.JS

I'm having trouble exporting data from AJAX/JQUERY to Morris.JS. The variable datachart returns with data, but the morris.js graph is not displaying any Line or Bar $("#diseaseselection").change(function(){ $("#chart").em ...

Stop the Bootstrap accordion from collapsing when clicking on an internal anchor (href)

Is there a way to prevent the accordion from collapsing when opening a new page after clicking on a link? I have included the HTML code below, but I need assistance with the JavaScript to achieve this. I'm facing an issue where the accordion category ...

Locate the nearest date (using JavaScript)

Searching for the nearest date from an XML file. <?xml version="1.0" encoding="UTF-8"?> <schedule> <layout fromdt="2014-01-01 00:00:00" todt="2014-01-01 05:30:00"/> <layout fromdt="2014-02-01 00:00:00" todt="2014-01-01 05 ...

What is causing this code to break when using ajax's `data` parameter?

I'm relatively new to JavaScript, and I've been working on some code that seems to be properly formatted. However, whenever I add the data elements, it breaks the code. I've checked the jQuery documentation and as far as I can tell, I'm ...

IE having issues with border display

I am looking to add borders to specific elements based on certain criteria, such as: Elements with the .xforms-required class that are not span elements OR input elements that are descendants of elements with the .xforms-required class To achieve this, ...

What is the best way to fill in and subsequently find matches using the 'parent' identifier?

I am currently working on associating a populated referenced document with the parent document id. The main objective is to display only the membership permissions related to a specific organization, rather than showing all other permissions that may exi ...

Issues with the functionality of the asynchronous socket.io JavaScript callback are being experienced

I am facing an issue with my JavaScript code that involves querying data from a database using Node.js and Socket.io. Currently, I have implemented setTimeout() functions to make it work, but I want to switch to using callbacks for better reliability. Howe ...

Update the hidden input's value by the ZIP code entered

I'm currently working on setting up arrays for specific regions and then comparing them to the zip code entered in order to designate the value of a hidden field (which signifies the region). No matter what I input, it always seems to result in "Not F ...

Generating intricate arrays from a given list

If I have an array containing various items like the following: [ ["Core", "Mathematics", "Mathematics 20-4"], ["Core", "Mathematics", "Mathematics 30-1"], ["Other", "Fine Arts", "Art", "some art course"], ["Other", "Fine Arts", "Music", " ...

I'm having difficulty integrating boostrap with my react application due to issues with the css-loader

In my React index.js file, I am importing Bootstrap and using Webpack 4: import React from 'react'; import ReactDOM from 'react-dom'; import './assets/css/index.css'; import App from './App'; import * as serviceWork ...

The code runs smoothly on Codepen, but encounters issues when executed through index.html

Click here to check out my issue tracker on Codepen! I recently created this handy tool for tracking issues, and it works perfectly in Codepen. However, when I tried to open it in Chrome browser, I encountered a console error: 'Uncaught TypeError: ...

What is the best way to incorporate a random JSON section into a JSON structure?

Let's say I have a JSON message: json_msg = [{ LOG: 'TPT', TYPE: 'UPDATE', UIN: 'VEHICLE', SEQ_NO: 20129, VALUE: 1, TIMESTAMP: 518342.438263017, EXPERIMENT: 0, IDENT: '.Model.Index_obj.MuLifeCycle_ob ...

How to retrieve and manipulate object properties in AngularJS after loading them from a service

In my AngularJS app, I have a local configuration file stored as a JSON file. I am using a service to fetch its content and then storing it in an object. The issue arises when trying to access the properties of this object outside of the callback function. ...

Issue with custom directive - bi-directional binding not functioning as expected

I'm currently working on creating a custom directive in Angular that transforms a tag into a toggle button, similar to a checkbox. As of now, the code I've developed updates the internal variable within isolated scope, but bidirectional binding ...

Innovative approach for setting up ES6 Grunt configuration

I'm currently setting up Grunt to utilize ES6, aiming to transpile each component's JS file into its own designated folder. Here is my current directory structure: Components └──footer │ └──js │ └──footer.jsx └ ...

Creating a web form with the ability to select multiple images using Javascript

Currently, I am in the process of developing an HTML form that enables users to select an image, a URL, and text that will be inserted as a <li> into a webpage. However, I am facing an issue where I want users to create multiple <li> per input. ...

Display every even number within the keys of objects that have values ending with an odd number

I need a way to print all even values that are paired with odd values in the object keys, but my code only works for arr1, arr3, and arr5. Can someone help me adjust the 'let oddArr' method (maybe using a loop) so that it will work for any array ...

Guide to transferring text to clipboard using PHP and JS

Forgive me if this sounds a bit silly. I've been trying to figure this out for a while now, and it seems like the only solution I found involves clicking some sort of button. I have a form that generates license keys, and after generating one, I wan ...

"Obtaining a MEAN response after performing an HTTP GET

I'm currently in the process of setting up a MEAN app, however I've hit a roadblock when it comes to extracting data from a webservice into my application. While returning a basic variable poses no issue, I am unsure how to retrieve the result fr ...