Creating a curved container with CSS styling

I've attempted to create a design resembling the image below, but I'm not achieving the desired result. Can someone provide me with assistance? Any help would be greatly appreciated.

https://i.sstatic.net/J4LzC.png

<!DOCTYPE html>
        <html>
        <head>
        <style> 
        #rcorners1 {
            border-radius: 10px 90px 90px 10px / 8% 100% 100% 8%;
            background: #18b1a0;
            padding: 20px; 
            width: 200px;
            height: 150px;    
        }
        </style>
        </head>
        <body>
        <p id="rcorners1">Rounded corners!</p>
        </body>
        </html>

Answer №1

Inspired by a suggestion from @Krusader, you may consider including position: relative; in #rcorners1. Additionally, you can introduce a pseudo element (::after) with the following CSS properties:

#rcorners1::after {
content: "";
position: absolute;
top: 10%;
left: -15px;
width: 30px;
height: 80%;
background-color: green;
border-radius: 100%;
} 

By incorporating these changes, your CSS will appear as follows:

#rcorners1 {
position: relative;
background: #18b1a0;
padding: 20px; 
width: 200px;
height: 150px;   
border-radius: 10px 90px 90px 10px / 8% 100% 100% 8%;
overflow: hidden;
}
#rcorners1::after {
content: "";
position: absolute;
top: 10%;
left: -15px;
width: 30px;
height: 80%;
background-color: green;
border-radius: 100%;
}

I trust this information is beneficial to you.

Answer №2

Could this be of assistance? ::

#rcorners1 {
    border-radius: 10px ;
    background: #18b1a0;
    padding: 20px; 
    width: 200px;
    height: 150px;  
    position: relative;
}

#rcorners1:after {
  content: '';
  background: #18b1a0;
  padding: 20px;
  width: 10px;
  height: 150px;
  position: absolute;
  right: -20px;
  z-index: -1;
  top: 0;
  border-radius: 0px 36px 36px 0;
}  

Answer №3

If you're looking for an alternative approach to the pseudo-element techniques, one option is to utilize the radial-gradient method (as suggested by Krusader in the comments). By combining two distinct radial-gradient effects as the background-image, you can achieve a dark shadow on one side and a curved border on the other. Adjusting the transparency levels will be essential to ensure the transition appears smooth and balanced.

Consider this example:

@import url('https://fonts.googleapis.com/css?family=Inconsolata');

.box {
  width: 190px;
  height: 109px;
  box-sizing: border-box;
  font-family: Inconsolata;
  font-size: 18px;
  background-image: radial-gradient(circle at -52%, rgba(0,0,0,0.25) 36%,  transparent 37%), 
                    radial-gradient(circle at 29%, #18b1a0 88%, transparent 89%);
  border-radius: 6px 25px 25px 6px;
  color: white;
  text-align:center;
  padding-top:36px;
}
<div class="box">SECRET<br/>CHAMBER</div>

Answer №4

Discover a variety of shapes for inspiration. https://css-tricks.com/examples/ShapesOfCSS/

Your code has been updated.

#rcorners1:after {

  bottom: 10px;
content: "";
position: absolute;
top: 10px;
left: 0;
width: 50px;
left: -35px;
background-color: #098a7c;
border-radius: 70px 100% 100% 70px;
}

#rcorners1 {
position: relative;
background: #18b1a0;
padding: 20px; 
width: 200px;
overflow: hidden;
height: 150px;   
border-radius: 10px 130px 130px 10px / 10px 100% 100% 10px;
}
<p id="rcorners1">Rounded corners!</p>

Answer №5

#container {
  border: 1px solid red;
  width: 500px;
  height: 250px;
  position: relative;
  overflow: hidden;
  }

  #right-corner-large,
  #right-corner-small {
  display: inline-block;
  width: 250px;
  height: 125px;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  margin: 0;
  }

  #right-corner-large {
  background-color: lightcoral;
  }

  #right-corner-small {
  background-color: red;
  position: absolute;
  top: 0;
  left: -240px;
  }
<div id="container">
<p id="right-corner-large"></p>
<p id="right-corner-small"></p>
</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 sending an ajax request with HTML data as the payload

While working on an MVC program, I encountered an issue when trying to send data from a TextArea to the controller upon a button click. Everything worked fine until I had HTML-based data inside the TextArea. Here's a snippet of the HTML code: <te ...

What are the steps to ensure that the content within the <pre><code></code></pre> tags displays correctly in Internet Explorer 7?

When using JQuery to make an AJAX pull with JSON to an ASP.net Web Service, the following code is used: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "TestWebService.asmx/Foo", data: "{}", dataType: "json", success: function( ...

Designing a structure with three fieldset components

I'm currently trying to design a page layout that includes three fieldsets. My goal is to have the first one span across 100% of the width, with the other two positioned side by side below it at 50% width each. However, I am struggling to achieve thi ...

Tips for fixing CORS error when working with the fetch API

I'm having trouble retrieving data from the metaweather.com API using JavaScript's fetch function. I attempted to include before the API URL, but it has not resolved the issue. I followed a video tutorial on how to fetch data, but I'm stil ...

Trouble with flex wrap in my design template using Material UI

How can I create a responsive template using flexbox wrapping method? <Box sx={{ padding: 0, margin: 0, listStyle: "none", display: "flex", flexFlow: ...

Title: "Customizing Labels on Stack Bars and Lines in D3.js Visualization"

Currently working on a stacked bar chart with a line chart on dual axis using D3.js and facing difficulty aligning labels correctly. Check out the code I have experimented with so far: https://plnkr.co/edit/doobXBC5hgzvGwDLvArF?p=preview I am looking to ...

Tips for hiding the initial value in an HTML Select tag

My HTML Select Program is very basic. By default, it displays "Volvo" as the first value. Is there a way to not display any initial value and allow the user to make a selection? <!DOCTYPE html> <html> <body> <form action="demo_form ...

What is the best way to eliminate the space following the image?

Something strange happened, and now there's a big gap following the top image. I was working on making the code responsive and then inserted this image, which messed everything up. Any ideas on what I might be doing wrong? I want the image to be close ...

Issues with centering background-position while using clip-path functionality

Struggling to center a background image? I initially suspected conflicting CSS rules, so I created a simplified demo to troubleshoot. After reviewing examples on SO and beyond, it seems like my approach is correct. Can anyone help identify what I might be ...

Developing Angular 6 for dynamic HTML navigation tabs

Being new to Angular 6, I recently created tabs in HTML and now need to convert them into Angular 6 while also making them dynamic. Here is the original HTML code: <ul class="nav nav-tabs side_nav" role="tablist"> <li role="presentation" class= ...

Is there a way to right-align the labels and input fields simultaneously?

Is there a way to line up the labels and inputs on the right side so they all appear in the same row? .radioContainer{ width: fit-content; margin: 5px; margin-top: 20px; background-color: aqua; padding-bottom: 25px; } <div class=" ...

Convert JSON objects within an array into HTML format

Is there a way to reformat an array of JSON objects that has the following structure? [{"amount":3,"name":"Coca-Cola"},{"amount":3,"name":"Rib Eye"}] The desired output in plain HTML text would be: 3 - Coca-Cola 3 - Rib Eye What is the best approach to ...

Unable to decipher Material UI class names

I am experimenting with a React app using Material UI to explore different features. I'm attempting to customize the components following the original documentation, but making some changes as I am using classes instead of hooks. However, I keep encou ...

Creating content on HTML AzureWebApp for transfer to CDS

Currently, my web app is running on azurewebsites.net. I am looking to extract data from a text field or captured photos and save it in the CDS / Dynamics 365 CE database. The website design is complete; I just need to focus on storing the data efficient ...

Is there a way to automatically update the input value when I refresh the page following a click event?

Currently, I have multiple p elements that trigger the redo function upon being clicked. When a p element is clicked, the quest[q] template is loaded onto the .form div. These templates are essentially previously submitted forms that sent values to an obj ...

Exploring the World of Bootstrap 4 Cards

Just starting out in UI/UX, I played around with some gallery transitions featuring hover effects, and incorporated Bootstrap cards into the mix. When I hover over the image (which was blank at first), it now displays an overlay with the intended text, alo ...

I am currently working on developing an HTML and JavaScript audio player that can play audio at specific scheduled times

Looking to create a custom HTML/JavaScript audio player that adjusts playback based on the time of day. For instance, if it's 1:00 pm, the file will start playing from 0:00 minutes; and if it's 1:01 pm, the file will begin playing from 1:00 minut ...

JQuery - stylish vertical accordion navigation menu

I'm currently working on a vertical accordion-style sidebar navigation system. Everything seems to be functioning properly, but I've encountered some issues with the icons that I'm using from Twitter Bootstrap 3. You can view the code on th ...

Tips for aligning a Bootstrap container in the middle of the viewport vertically

I'm struggling to center a Bootstrap container vertically in the viewport. You can view my code at http://www.bootply.com/C8vhHTifcE All of my attempts at centering have been unsuccessful. Does anyone have a solution? Just to clarify: I want the co ...

Tips for avoiding cursor sticking in css rotate transform in firefox?

I have a unique challenge in this code where I want the user to grab the black square and rotate it around the inner circle. Check out the code snippet here. While attempting to rotate the square, you might notice that the cursor sometimes gets stuck in ...