Curved in a dual manner

Currently, I am trying to create a unique 'wavy ghostly bottom' shape that features two double curves:

While the lower portion of this illustration captures it more effectively.


My Code

My latest attempt at generating this shape involved using pseudo-elements and overflow: hidden, but it restricts the use of gradient backgrounds (as a solid color background is required):

Attempt 1 - Using Pseudo Elements with overflow hidden

.bottom {
  height: 300px;
  width: 300px;
  background: lightgray;
  position: relative;
  overflow: hidden;
  margin-top: -150px;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}
.bottom:before, .bottom:after{
  position: absolute;
  content: "";
  background: white; 
}
/* Rest of CSS code */

Attempt 2 - Using Pseudo Elements with 's' shape

.bottom {
  background: lightgray;
  /* Rest of CSS code */
}

Attempt 3 - extra elements and box shadows

I experimented with adding box shadows and extra elements as well, but couldn't quite achieve the desired result:

.bottom {
    height: 300px;
    width: 300px;
    position: relative;
    overflow: hidden;
}
/* Rest of CSS code */

None of these methods seem to provide an easy way to create the double curved shape without requiring a solid colored background.

Note: I prefer not to use SVG as I have completed most of the overall shape using pure CSS, so I'd like to finish this without an SVG element.


The inner shape will have a solid color, and the border is not crucial in my design.

Here is where I want to implement it


Update

Answer №1

Reflecting on :

  • the volume of code required
  • the complexity of aligning double curves

It appears that CSS may not be the most suitable option in this scenario and SVG is far more fitting. To exemplify, take a look at these two code snippets :

SVG

DEMO

/*** FOR THE DEMO **/
svg{
    display:block;
    width:70%;
    margin:0 auto;
    opacity:0.8;
}
body{
    background: url('http://lorempixel.com/output/people-q-g-640-480-7.jpg');
    background-size:cover;
}
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 80">
    <path stroke-width="1" stroke="#000" fill="grey" d="M95 5 Q70 20 70 38 T50 65 Q55 50 30 40 T5 5z"/>
</svg>

CSS

DEMO (note that only one double curve has been created on the right side of the shape)

.ghost {
  position: relative;
  width: 400px;
  height: 300px;
  margin: 0 auto;
  overflow: hidden;
}
.ghost:before,
.ghost:after {
  content: '';
  position: absolute;
}
.ghost:before {
  bottom: 0;
  right: 50%;
  width: 70%;
  height: 30%;
  transform-origin: 100% 100%;
  transform: skewY(30deg) rotate(20deg);
  box-shadow: -100px -100px 0px 99px #656565;
  border-top-right-radius: 30% 100%;
}
.ghost:after {
  top: 0;
  right: 0;
  transform-origin: 100% 0;
  transform: skewX(-10deg) rotate(-20deg);
  box-shadow: none;
  height: 107px;
  width: 173px;
  border-top-left-radius: 90% 100%;
  box-shadow: -30px -30px 0px 29px #656565, 60px -110px 0px 109px #656565;
}
<div class="ghost">
</div>

Please note that I have not outlined the benefits of using an SVG in this instance (responsiveness, output quality, control over curves, borders, border color/transparency, fill color/transparency, maintainability, time taken to craft the shape...)

Answer №2

To create that shape, you can utilize box shadows and overflows.

body {background:url('http://whofortedblog.com/wp-content/uploads/2013/01/33c9f33218a6cab6054375fb76129a80.jpeg');
background-size: cover;}
div {
  height: 100px;
  width: 200px;
  overflow: hidden;
  position: relative;
  -webkit-transform: scale(1,1.1);
  -moz-transform: scale(1,1.1);
  -ms-transform: scale(1,1.1);
  -o-transform: scale(1,1.1);
  transform: scale(1,1.1);
}
div:before {
  height: 80px;
  width: 100px;
  border-radius: 50% / 50%;
  box-shadow: 40px -11px 0 -20px white, 42px -22px 0 -10px white, 50px -28px 0 -8px white, 36px -95px 0 20px white;
  content: "";
  position: absolute;
  -webkit-transform: scale(0.9,1.1);
  -moz-transform: scale(0.9,1.1);
  -ms-transform: scale(0.9,1.1);
  -o-transform: scale(0.9,1.1);
  transform: scale(0.9,1.1);
  top: 50%;
  left: -10px;
}
div:after {
  height: 70px;
  width: 120px;
  border-radius: 50%;
  -webkit-transform: rotate(-35deg);
  -moz-transform: rotate(-35deg);
  -ms-transform: rotate(-35deg);
  -o-transform: rotate(-35deg);
  transform: rotate(-35deg);
  box-shadow: ;
  content: "";
  position: absolute;
  top: -1%;
  box-shadow: -1px -28px 0 5px white;
  right: -35px;
}
<div></div>

Enhance this design further by adjusting the positioning values! Regardless, it's recommended to consider using a PNG image or SVG for a cleaner solution.

How It Works:

div {
  height: 100px;
  width: 200px;
  overflow: hidden;
  position: relative;
  border: 1px solid black;
}
div:before {
  height: 80px;
  width: 100px;
  border-radius: 50% / 50%;
  background-color: red;
  box-shadow: 40px -9px 0 -20px blue, 42px -20px 0 -10px pink, 50px -25px 0 -8px plum, 37px -95px 0 20px green;
  content: "";
  position: absolute;
  top: 50%;
  left: -10px;
}
div:after {
  height: 70px;
  width: 120px;
  border-radius: 50%;
  background-color: rgba(255, 215, 0, 0.6);
  -webkot-transform: rotate(-35deg);
  -moz-transform: rotate(-35deg);
  -o-transform: rotate(-35deg);
  -ms-transform: rotate(-35deg);
  transform: rotate(-35deg);
  box-shadow: ;
  content: "";
  position: absolute;
  top: -1%;
  box-shadow: -4px -27px 0 5px rgba(0, 255, 215, 0.6);
  right: -44px;
}
<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

Challenges related to height

Having an issue with height in my code. My footer is set up like this: <html> <body> <div class='wrap'> <div class=principal></div> <div class='clear'></div> <foo ...

Instructing my config.rb file to direct my compiled .scss file output to the main root directory

My goal is to configure my CSS output file in the config.rb file to be located at the root level of my main directory and named "style.css". Everything works fine when I set all the filepaths in config.rb like this: http_path = "/" css_dir = "assets/css" ...

How come the sticky header isn't functioning within form tags with Bootstrap 4?

Why are the form inputs or buttons overlapping my navigation header? Everything works fine when I don't use bootstrap 4. I need the header to always be on top of all elements in my website. Is there a way to resolve this using only Bootstrap without ...

Having trouble getting the height to work properly on your Blogger Blogspot template?

Issue with embed height=100% not working <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> & ...

Print media not affected by Bootstrap styling

Below is the code I am using to display a table within my application: var elementToPrint = this.mainTable.get(0); newWin = window.open(""); newWin.document.write('<html><head><title>' + elementToP ...

The colors don't seem quite right on my Nokia Windows Phone

Here is the link to my website: You can find the source code here: https://github.com/Yorkshireman/pamplona_english_teacher2 The background design features a subtle gradient. I have implemented an autoprefixer to ensure compatibility with different brow ...

PHP - Utilize get_option to send styling options to style.php

I'm having trouble figuring out how to structure my question, but in my plugin folder I have 2 files: 1 - "index.php" add_action( 'wp_enqueue_scripts', 'register_plugin_styles' ); function my_admin_setting() { include(' ...

Adjusting the positioning of two elements inside a container

Contained within the #search-bar div is a clickable image and an h1 element (unfortunately, I am unsure where to place the relevant image.. my apologies). My goal was to separate them as shown. I'm curious if there might be a simpler and more concise ...

Tips for updating the background color of a select option

I'm looking to customize the background color of select options in my Bootstrap 4 form. Can anyone provide guidance on how to achieve this? `` <div class="form-group "> <select class="form-control > <option va ...

How to conceal the bottom bar in JQuery Colorbox iframe

I have implemented colorbox to showcase an Iframe of the registration page on my website. Here is how it looks... https://i.sstatic.net/z1RGK.png Upon closer inspection, I noticed a white bar at the bottom of the Iframe where the close 'X' butt ...

Overlaying text on several images

My challenge is centering text over multiple images using a combination of Bootstrap and CSS. While most online resources suggest using position: absolute; to achieve this, I have only been successful in centering the text in the middle of the screen rathe ...

Creating a gradient border around a div using CSS3

Can a border like this be achieved using only CSS, or will I need to use an image? ...

CSS KeyFrame animations

My goal is to have my elements gracefully fade in with 2 lines extending out of a circle, one to the left and one to the right. However, I am struggling to achieve this. Every time I attempt to display the lines, it ends up shrinking the entire design. M ...

Tips for incorporating personalized CSS properties, such as font-size, into all Django admin pages

Currently, I am in the process of developing a project using Django. My goal is to implement custom CSS properties, such as font-size, across all Django admin pages - including User change and User add pages - simultaneously. This would streamline the proc ...

Tips for utilizing Bootstrap 4 exclusively within a designated Bootstrap Modal

Currently, I am working on an application that utilizes Bootstrap 3. Unfortunately, the Bootstrap 3 files (.css/js) have undergone extensive modifications. My task involves integrating the SummerNote Text editor, and although everything is functioning corr ...

Challenges with Image Placement and Alignment

Having trouble with the sizing of my image in the skill portion of my website. The clouds and mountains look fine, but for some reason, the image isn't the same size. Additionally, the text "full stack developer" is not centered under my name anymore ...

Is there a way to prevent the contents of my div from overflowing beyond my other div?

Hey there! I'm fairly new to this whole web design thing, only a few months in. Currently, I'm in the process of creating a website for my school. However, I've hit a bit of a snag with different div containers holding various parts of my ...

What is the best way to bridge the gap between the rows?

After combining the top and bottom blocks, I now have a gap in my layout. Is there a way to move this row up without causing any issues? I need assistance with resolving this problem using Bootstrap. <link rel="stylesheet" href="https://maxcdn.boots ...

Adjust the styling with jQuery according to the selected value from the dropdown menu

Check out this Fiddle I have a jQuery script that is supposed to change the style of an input box to display:block if the selected value is "<>" (Between). However, currently it is changing the css for all selected items instead of just the target i ...

``Are there any thoughts on how to troubleshoot display problems specifically on mobile

Whenever I use Safari on iOS for my web application, I encounter strange rendering issues. It's odd because the majority of the time everything functions as it should, but every now and then these bugs crop up with no discernible pattern. Examples th ...