Curved interior box

I have been attempting to design an 'inside curved box' without much luck, I can't seem to locate any online examples. Could someone assist me in creating this using CSS or possibly SVG?

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

Answer №1

If you want to create a shape with a solid color background on a page that is not solid, one way to do it is by using a pseudo-element and a box-shadow with a high spread radius. This solution may seem like a hack but it should work on most browsers as box shadow has good support.

div{
  position: relative;
  height: 300px;
  width: 150px;
  border-radius: 12px;
  overflow: hidden;
}
div:after{
  position: absolute;
  content: '';
  height: 30px;
  bottom: -15px;
  width: 100%;
  left: 0px;
  box-shadow: 0px 0px 0px 500px blue;
  border-radius: 12px;
}

body{
  background: linear-gradient(chocolate, brown);
  height: 100vh;
}
<div class='shape'></div>


Another way to achieve the same effect is by using SVG path elements, as shown in the snippet below.

div {
  height: 300px;
  width: 150px;
}
svg path {
  fill: blue;
}
body {
  background: linear-gradient(chocolate, brown);
  height: 100vh;
}
<svg viewBox='0 0 150 300' height='0' width='0'>
  <defs>
    <g id='shape'>
      <path d='M0,12 A12,12 0 0,1 12,0 L138,0 A12,12 0 0,1 150,12 L150,300 A12,12 0 0,0 138,288 L12,288 A12,12 0 0,0 0,300z' id='fill' />
    </g>
  </defs>
</svg>

<div class='shape'>
  <svg viewBox='0 0 150 300' preserveAspectRatio='none' vector-effect='non-scaling-stroke'>
    <use xlink:href='#shape' />
  </svg>
</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 if a website refuses to be embedded in an <IFrame>? Is there a workaround to still embed it?

I'm trying to include a 'www.youtube.com' video using the IFrame tag in HTML, but unfortunately it's not allowing me to embed it. Is there a workaround or different method I can use to achieve this? ...

Highlighted text area: offsetting occurs when empty lines are present

I'm trying to implement a multi-value textarea that reads and writes from/to an ng-model(array). Additionally, I have a div (highlighter) acting as a mask with the same values as the ng-model. It highlights values that return false for "NaN(value)". ...

Adding content to an empty element will not produce the desired result

I'm trying to show each character of a string, which is stored in an array, one at a time. However, when I use threadsleep(a) with the code found here: http://jsfiddle.net/thefiddler99/re3qpuoo/, all the characters are displayed at once. There seems t ...

Is there any way to determine if Bootstrap has been utilized to build my WordPress page?

I'm currently contemplating if it's worth incorporating Bootstrap into my pre-existing Wordpress site. During my research, an interesting thought crossed my mind - could the template I'm utilizing already be built with Bootstrap? Although a ...

Creating an overflow effect for sliders using only CSS

Is it feasible to develop a slider that extends beyond its parent elements and the body? The concept involves having content within a section housed in a container. The slider would be part of this section, with slides overflowing past the parent element ...

Is there a way to implement tooltips on an element that has text-ellipsis enabled?

I am facing an issue with displaying an account number that exceeds 100 characters. I need to restrict the display with overflow hidden while still being able to show the full account number using a tooltip. Below is the code snippet: <span class="tex ...

Excessive empty space appears on my mobile screen

Is there a solution to remove the white space issue that only occurs in mobile view? Here is an image of the problem: Untitled: https://i.sstatic.net/6WcGy.png I attempted using responsive instead of fluid, but it only resulted in the image being scaled ...

The asp:TextBox functionality encounters issues when used within the asp:Placeholder element using C#

I'm attempting to dynamically add TextBoxes controls based on items in my database. Below is the asp:PlaceHolder snippet from my .aspx page: <asp:PlaceHolder ID="PlaceHolderHTML" runat="server"></asp:PlaceHolder> From my C# code, I am ge ...

Building a nested table within a parent table in bootstrap is a breeze

Can you provide guidance on nesting tables in Bootstrap-3? Whenever I attempt it, the second table ends up being displayed after the first one. ...

How can I create curved text in Three.js?

I'm currently experimenting with Three.js in an attempt to create an object featuring curved text. Would using TextGeometry be the most appropriate approach for this task? var material = new THREE.MeshPhongMaterial({ color: 0xdddddd }); var ...

Textarea Colspan Not Functioning as Expected

Currently, I am tackling a project in ASP.NET MVC where the colspan for textarea seems to be ignored despite setting it as colspan="2". CSS table { border-collapse: separate; border-spacing: 0; } td { position: relative; ...

How come my webpage is not loading properly with CSS applied?

My website can be found at: www.rootscope.in While working on the CSS for my site, I encountered an issue with the following code: .loader { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 9999; backgroun ...

Aligning a Bootstrap button beneath text that is centered on the page

I want to include a button below some text in the contact section. The text reads "get in touch" at the center of the page, but when I add a button it appears under the text and aligned to the left. I need it to be centered on the page beneath the text. ...

Material UI Grid's layout does not support placing a select element within a row

As a newcomer in the world of full stack development, I am delving into coding projects to enhance my understanding of frontend technologies like React JS and Material UI. My latest endeavor involves creating a page that displays posts from the backend in ...

Tips on showcasing information with ng for in Ionic 2

https://i.sstatic.net/MKIcJ.jpgI am currently working on the thank you page for my project. When the success call is made, it will display both ORDER DETAILS and Delivery Details. However, in the event of a failure call, only the ORDER DETAILS are displaye ...

iOS Safari enlarges frameset beyond viewport limits

I am currently designing a website that utilizes a frameset featuring a horizontal split - a menu sidebar on the left and a content area. <!DOCTYPE html> <html> <head> <title>Frameset Test</title> </head> ...

The "html" element fails to achieve a full height when applying a 100% height setting

I am facing a height problem of 100% <!doctype html> <html> <head> <meta charset="utf-8"> <title>My Dreamweaver Website</title> <link rel="stylesheet" href="style.css"> </head> <body> <section clas ...

Is there a way to ensure that the fixed modal remains at the forefront and that its top stays in view even as the user scrolls?

Can you assist me in simplifying this code? import { LoginProps } from '@/layouts/layout.props'; import { Box, Button, Divider, Flex, FormControl, FormLabel, Heading, HStack, IconButton, Input, Link, Stack, Text, } from ...

Affix Object to Bottom of Stationary Element

I have a header element that I want to remain fixed while scrolling. The scrollable area should be positioned directly after the fixed header, without using position: absolute and removing it from the document flow. To better illustrate the issue, I' ...

.htacces Disables Styling on Page

I've been trying to understand the functionality of .htaccess RewriteRule. Here is a URL example where I have experimented with .htaccess: http://example.com/test/home This used to be: http://example.com/test/index.php?p=1 My goal is to redirect ...