Crafting a unique rounded rectangle with an Inverted S-curve design using CSS and HTML

In an attempt to replicate the design showcased in the image provided via link, I am working on creating a rounded rectangle with an "S-curve" effect at the bottom. To achieve this, my current approach involves utilizing a parent element (hero_right) with two child elements (hero_right_top and hero_right_bottom). The idea is to set the top element to 70% height and the bottom element to 30% height, while applying border properties to create the desired rounded effect.

https://i.sstatic.net/jtrmBiEF.png Image#1

The challenge lies in shaping the bottom-left portion to achieve the intended S-curve effect. Although attempting to set the width of the bottom element to 90%, positioning it absolutely to the right, and then implementing border-radius to the corners, the outcome isn't quite as expected. Furthermore, adding a nested div inside the bottom element with absolute positioning and additional border-radius doesn't yield the desired result.

This is the code snippet I have worked on so far:

HTML:

<div className='hero_right'>
    <div className="hero_right_top"></div>
    <div className="hero_right_bottom">
        <div href="#" className="hero_right_bottom_link"></div>
    </div>
</div>

CSS:

.hero_right {
    position: relative;
    display: flex;
    flex-direction: column;
}

.hero_right_top,
.hero_right_bottom {
    min-height: 71.5%;
    width: 100%;
    background-color: var(--thirdColor);
}

.hero_right_bottom {
    min-height: 30%;
}

.hero_right_top {
    border-top-right-radius: 100px;
    border-top-left-radius: 100px;
    border-bottom-left-radius: 100px;
}

.hero_right_bottom {
    position: absolute;
    width: 90%;
    right: 0;
    bottom: 0;
    border-bottom-right-radius: 100px;
    border-bottom-left-radius: 100px;
}

.hero_right_bottom_link {
    position: absolute;
    top: 0;
    left: -3%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    align-content: center;
    text-decoration: none;
    color: var(--primaryColor);
    width: 60px;
    height: -webkit-fill-available;
    border-top-right-radius: 158px;
    background-color: var(--whiteColor);
}

https://i.sstatic.net/JpoRErr2.png Image#2

The issue persists as the bottom-left part does not shape precisely as intended. Seeking guidance on how to effectively achieve this S-curve effect using CSS. Welcome any suggestions or modifications to enhance my current approach. Thank you.

Answer №1

To achieve the desired effect, utilize a clip-path with an SVG path().

In this case, I extracted the path from the graphics using Affinity Designer, then exported it as an SVG with a single <path>. After optimizing the export with SVGOmg and making minor adjustments with my SVGPathology tool, the final path was ready to be used. If you have the design in vector format, there's no need to manually trace it – simply move the orange path to the drawing's origin and export it.

#outer {
  position: relative;
  width: 720px;
}
#orange {
  position: absolute;
  top: 0;
  left: 0;
  background: orange;
  font-size: 32pt;
  width: 720px;
  height: 750px;
  clip-path: path('M0 89C0 40 40 0 89 0h485a43 43 0 0 1 43 43v8a44 44 0 0 0 43 43h4a52 52 0 0 1 52 52l-2 511c0 51-42 93-93 93H198a90 90 0 0 1-90-90V505c0-26-21-46-47-46h-8c-29 0-53-24-53-53V89Z');
}
#blob1 {
  position: absolute;
  top: 0;
  right: 10px;
  background: #111;
  width: 80px;
  height: 80px;
  border-radius: 100%;
  text-align: center;
  font-size: 50px;
  line-height: 1;
  align-content: center;
}
<div id="outer">
  <div id="orange">This is in the orange container. This is in the orange container. This is in the orange container. This is in the orange container. This is in the orange container.</div>
  <div id="blob1">🌍</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

Adjust the size of an SVG to perfectly fit within a designated div

I've looked through several discussions here, but none of the suggested solutions seem to work for my specific situation. My issue involves an SVG that was created on a different website. It contains three elements, and I'd like to embed it whil ...

Dynamic SVG circles with timer and progress animation

Is there a way to modify the following: var el = document.getElementById('graph'); // get canvas var options = { percent: el.getAttribute('data-percent') || 25, size: el.getAttribute('data-size') || 220, lineW ...

CSS dilemma: A snag with pointer-events and the a:focus attribute

Does anyone have experience troubleshooting issues with navbars? I could really use some help. I am facing an issue with my navigation bar where I have different links that reveal an unordered list of sublinks upon clicking. The CSS for my <ul> is ...

The navigation menu dissolves into hiding at the uppermost part of the page upon scrolling upwards on iOS devices

I am currently working on creating a navigation menu that will automatically hide when scrolling down and reappear when scrolling up. This functionality works perfectly fine on desktop and Android browsers, but I have encountered an issue specifically with ...

Designing a website with a 4x4 layout grid

How can I create a webpage with a 4x4 grid that changes colors in each square when clicked on? Appreciate any advice! ...

What could be the reason for the event not being triggered multiple times?

Currently, I am in the process of designing follow/unfollow buttons for various members within a system. However, I am encountering an issue where the jQuery event does not trigger after the HTML is re-rendered within the same div containing the buttons. T ...

Troubleshooting Problem with Integrating ControllerAs in AngularJS Routing and Application.js

Can someone please help identify the errors in the code? Issue 1: The Save button in addstudent.html is not functioning properly. It works with $Scope, but after modifying the code to use ControllerAs, the functionality ceased. Debugging revealed that con ...

Exiting the modal/popup box is currently disabled

I am struggling to figure out why the modal box/pop up is not closing when I click 'x'. It seems completely unresponsive. Check out the JavaScript code below: var kite = document.getElementById("poptext"); var kitetwo = document.getElementById( ...

Aptana throws a fit over a script that's as empty as

Within Aptana, I am encountering an issue with the following line of code: <script type="text/javascript" charset="utf-8" src="js/jquery-1.7.2.js"></script> Alternatively, it could be written as: <script type="text/javascript" charset="ut ...

Navigating Up a Directory with JQuery

Is there a way to navigate up one directory level in my jQuery code? The code below is referencing a folder named "uploads" on the C drive, but I can't find any mention of "uploads" in my HTML. How does it know to look there? And how can I go back to ...

The input tag led to a twofold increase in output

I'm facing an issue with my output that I'd like to address. I need to halt a specific refresh loop in a particular field text tag, where my search text bar duplicates when a specific div is refreshed. I have implemented AJAX as a refresher in ...

Ways to create a fixed top navigation bar that adjusts content similarly to a non-fixed navbar

I'm looking to achieve a fixed navbar at the top that pushes down content when I open the collapse menu, similar to how it functions in static or regular navbars. Something like this example: (https://getbootstrap.com/examples/navbar-static-top/) but ...

Removing a outside div element based on a dropdown change in ASP.NET jQuery

this is the structure of my unique div <div class="row-fluid"> <div class="span12"> <div style="overflow: auto; width: 90%;" class="goleft"> <div style="display: inline-block; width: 200px;"> ...

Is there a way to determine the location where my website is fetching CSS and media files from?

After implementing Wagtail on my website, I encountered an issue with the CSS and images not being found when the site was put into production. I have already tried running python manage.py collectstatic and ensured that all of my CSS files are located in ...

Creating multi-level nested lists with numbering using HTML and CSS

Is there a way to create a unique numbering format using only HTML and CSS lists (<ul> or <ol>)? 1. Item A 2. Item B 3. Item C 3.1. Subitem C.1 3.2. Subitem C.2 3.3. Subitem C.3 4. Item D 4.1. Subitem D.1 4.1.1 Sub-subi ...

Adjust Node visibility as User scrolls to it using CSS

Suppose I have a structure like this: <br><br><br>...Numerous BRs...<br><br><br> <div id="thetarget"></div><div id="show"></div> <br><br><br>...Numerous BRs...<br><br&g ...

What could be causing my Bootstrap 5 hover effect to malfunction?

Can anyone help with changing the hover effect of a bootstrap button in my code? Here's the HTML: <button type="button" class=" btn btn-dark">Sign Up</button> And here's the CSS I tried: .btn-dark:hover { color: ...

The navigation menu is stuck and will not toggle

I'm having trouble getting the button to toggle the nav bar to work properly. I've gone through similar questions and checked my html, but still can't figure out the issue. Any help would be greatly appreciated! Although I can see all the l ...

Opt for filling background image instead of stretching it when the screen is resized

My background image resizes with the screen height but stretches when I change the width. The content that should appear below it completely covers the image. This is my current code: HTML: <div id="bg"> <img src="http://placehold.it/2560x1 ...

Exploring the world of web development with a mix of

var articles = [ {% for article in article_list %} {% if not forloop.first %},{% endif %} { title: "{{ article.title }}", slug: "{{ article.slug }}", content: "{{ article.content }}", auth ...