What is the best way to create stylish corners on my website?

I'm struggling with creating a corner like the one shown in the image.

As a beginner in frontend development, I attempted to write the following code but now I'm stuck.

The Snippet:

* {
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  background-color: white;
  border-radius: 15px
}

.box {
  text-align: center;
  font-size: 50pt;
}

#top {
  background-color: blue;
  position: relative;
  border-bottom-left-radius: 50px
}

#top:after {
  content: "";
  position: absolute;
  right: 0;
  top: 100%;
  height: 100px;
  width: 100px;
  border-top-right-radius: 50%;
  box-shadow: 0 -50px 0 0 black;
}

#bottom {
  background-color: red;
  position: relative;
}
<div class="container">
  <div class="box" id="top">Top</div>
  <div class="box" id="bottom">Bottom</div>
</div>

This HTML and CSS code demonstrates how to create a webpage with a centered container containing two boxes - one with a blue background labeled as "Top" with a decorative shadow, and the other with a red background marked as "Bottom". The design features rounded corners and centered text.

Answer №1

To achieve the desired effect, it is recommended to wrap additional containers around the top and bottom sections with a different background color.

* {
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  background-color: white;
  border-radius: 15px
}

.box {
  text-align: center;
  font-size: 50pt;
}

#OuterTop {
  background-color: red;
}

#OuterBottom {
  background-color: blue;
}

#top {
  background-color: blue;
  position: relative;
  border-bottom-left-radius: 50px;
}

#bottom {
  background-color: red;
  border-top-right-radius: 50px;
  position: relative;
}
<div class="container">
  <div id="OuterTop">
    <div class="box" id="top">Top</div>
   </div>
  <div id="OuterBottom">
    <div class="box" id="bottom">Bottom</div>
  </div>
</div>

Answer №2

This method involves using a dual-color background (left and right).

:root {
  --clear    : #e8eaff;
  --dark     : #18183a;
  }
* {
  margin     : 0;
  box-sizing : border-box;
  }
.container { 
  border-radius : 30px;
  width         : 200px;
  background    : linear-gradient(90deg, var(--clear) 50%, var(--dark) 50%);
  margin        : 2em;
  } 
.container > div {
  border-radius : inherit;
  padding       : 30px;
  }
.container > div:first-of-type {
  background : var(--dark);
  color      : var(--clear);
  height     : 150px;
  }
.container > div:last-of-type {
  background : var(--clear);
  color      : var(--dark);
  height     : 200px;
  }
<div class="container">
  <div>Top</div>
  <div>Bottom</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

What is the best method for organizing data in rows and columns?

I attempted to use my map function to iterate over the data and display it, but I struggled to format it into rows and columns. The requirement is for 5 fixed columns with dynamically changing rows, making array indexing impractical. Here is the code snip ...

Attempting to integrate the Angular2 module text-mask-addon into the project

Currently, I am in the process of integrating text-mask-addons into my Angular application. You can find more information at https://github.com/text-mask/text-mask/tree/master/addons Despite attempting to follow the npm links suggestion, I am encountering ...

Utilizing Bresenham's line drawing algorithm for showcasing box contours

I am seeking a similar behavior to what is demonstrated on , but with some modifications to the boxes: div { display: inline-block; width: 100px; height: 100px; border: 1px solid black; cursor: pointer; } div.selected, div:hover { backgroun ...

Elegant rounded bordered sidebar design to highlight selected navigation items using HTML and CSS

I am looking to replicate the sidebar design displayed in the image below by using HTML and CSS. While I have successfully rounded the borders on the left side of a selected link, I am stuck when it comes to rounding the borders on the right side. https:/ ...

Breaking down a string and then retrieving elements from an array

Just diving into the world of Javascript and jQuery, so I have a simple query. I've got a date that I need to break down into a string and then display it as an array. var date = "12/10/2010"; var dateArray = date.split(/); $('#printbox') ...

Challenging jQuery AJAX journey

After tirelessly searching the web, I am still unable to solve this issue and cannot understand why it is not functioning. My JavaScript code seems to work only on Firefox and fails to run on any other browser. So, I have made the decision to switch to j ...

What could be causing the reliability issue with this particular Angular JS code for dropdown menus?

Attempting to create a dynamic country-city dropdown menu using AngularJS <div> Country: </br> <select data-ng-model="country" ng-options="country.name for country in countries" data-ng-change="updateCountry(country) ...

the value contained in a variable can be accessed using the keyword "THIS"

I recently developed a snippet of code that adds a method to a primitive data type. The objective was to add 10 to a specified number. Initially, I had my doubts about its success and wrote this+10. Surprisingly, the output was 15, which turned out to be ...

Text that fades in and out based on scrolling past a specific point

There's a text containing <p> and <h1>. The text finishes with one <h1>. I'm looking to speed up the Y translation of the <p> twice when I reach the bottom of the document (where the last h1 is located in the middle of th ...

Struggling to align elements in React/JS/M?

My challenge is aligning the elements in the middle of my page. I aim to have 3 elements per row, with n rows depending on the number of "VideoBox" components. It's crucial that these elements fit within the lettering of the P R O F E S S I O N A L ...

Creating a tiled grid layout using Bootstrap 3

I’m grappling with a masonry layout issue while using Bootstrap. In my code, I have 5 divs but I’m struggling to get Div 4 and 5 to move up as shown in the attached image. While using margin-top is a quick fix, it disrupts the responsive design. Any su ...

Enable automatic scrolling when a button on the previous page has been clicked

Imagine there are two buttons (Button 1 and Button 2) on a webpage (Page A). Clicking on either button will take you to the same external page (Page B). How can we ensure that Button 1 takes you to the top of Page B, while Button 2 automatically scrolls do ...

jQuery search and filter functionality ineffective for unordered list of states and cities

CONTEXT: I am aiming to display a list of States initially. There are two options: either clicking on a state will reveal the respective cities, or using the search box will filter cities across all states - clearing the search will hide everything. ISSU ...

Shift the content downwards within an 'a' snippet located in the sidebar when it reaches the edge of the right border

I'm having an issue with my style.css file. As a beginner in programming, I am trying to position text next to an image attached in the sidebar. However, the text is overflowing past the border. Here's the HTML code: Please see this first to ide ...

Make sure to use the jQuery load function to specifically target and retrieve

Hello, I'm new to working with jQuery and I have a question about adding a vertical scrollbar to a jQuery modal window. Specifically, I want the scrollbar to appear when there is a large amount of text within the modal window. Can you guide me on wher ...

Tips for designing a search bar using Angular

search : ____________ I am interested in designing a search bar functionality that automatically triggers when the user inputs 8 or more characters. The input text will be stored in a variable, the search bar will be reset, and the backend API will be che ...

I aim to arrange three div elements in a single row with varying widths - placing one on the left, another in the center, and the last

I am trying to have three div elements in one row with different widths - one on the left, one in the center and one on the right. The left div should be 160px The center div should be 640px The right div should be 160px My goal is for them to appear se ...

Divs in jQuery smoothly slide down when a category is chosen

As I work on a large website, I have hidden div tags in my HTML that I want to be displayed when a user selects a specific category. However, due to the size of the site, there are many hidden divs that need to be revealed based on different categories sel ...

The div is set to a position of absolute, causing the overflow-y property to be set to auto. As a

I am facing an issue with a div that has absolute positioning nested inside other divs. If you take a look at the code snippet below from http://jsfiddle.net/d8GYk/, you'll notice the styling properties applied to the div. <div style="position: ...

fill the designated column in accordance with the specific criteria

Is there a method to automatically fill in a specific column based on certain conditions? I am looking to populate the column labeled [Last] when the column index is 1 and the corresponding name is [First]. import {Component, OnInit} from '@angular ...