Create a design using CSS that features rounded borders on three sides and one side with a disconnected corner

Could you help me with designing a CSS design that is found in the following link?

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

Answer №1

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>My Document</title>
</head>
<style>
    .upperdiv {
        width: 200px;
        height: 80px;
        border: 1px solid;
        border-radius: 25px;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .upperdiv::before {
        position: absolute;
        padding: 2em;
        border-radius: 50%;
        content: '';
        background: white;
    }

    .TL::before {
        margin: -28px;
        padding: 2em;
    }

    .TR::before {
        margin: -28px;
        margin-left: 167px;
    }

    .lowerdiv {
        width: 200px;
        height: 80px;
        border: 1px solid;
        border-radius: 25px;
        border-top: 0px solid;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .lowerdiv::before {
        position: absolute;
        padding: 2em;
        border-radius: 50%;
        content: '';
        background: white;
    }

    .BR::before {
        margin: -28px;
        margin-top: 45px;
        margin-left: 167px;
    }

    .BL::before {
        margin: -28px;
        margin-top: 45px;
        margin-left: -33px;
    }

    .container {
        margin: 3em;
        display: inline-block;
    }
</style>

<body>
    <div class="container">
        <div class="upperdiv TL"></div>
        <div class="lowerdiv"></div>
    </div>

    <div class="container">
        <div class="upperdiv TR"></div>
        <div class="lowerdiv"></div>
    </div>

    <div class="container">
        <div class="upperdiv"></div>
        <div class="lowerdiv BR"></div>
    </div>

    <div class="container">
        <div class="upperdiv"></div>
        <div class="lowerdiv BL"></div>
    </div>
</body>

</html>

Answer №2

One way to achieve this is by implementing the following design.

.container {
  width: 100px;
  height: 50px;
  background: #FFF;
  border-radius: 10px;
  border: 1px solid #000;
  position: relative;
  float: left;
  margin: 5px;
  font-size: 10px;
  line-height: 25px;
  text-align: center;
}

.contentsTop {
  width: 100%;
  height: 25px;
  position: absolute;
  left: 0px;
  top: 0px;
  z-index: 1;
}

.contentsBottom {
  width: 100%;
  height: 24px;
  position: absolute;
  left: 0px;
  top: 25px;
  border-top: 1px solid #000;
  z-index: 1;
}

.hideCorner {
  height: 10px;
  width: 10px;
  background: #FFF;
  position: absolute;
}

.top-left {
  top: 0px;
  left: 0px;
}

.top-right {
  top: 0px;
  right: 0px;
}

.bottom-left {
  bottom: 0px;
  left: 0px;
}

.bottom-right {
  bottom: 0px;
  right: 0px;
}
<div class="container">
  <div class="hideCorner top-left"></div>
  <div class="contentsTop">TOP LEFT</div>
  <div class="contentsBottom">TOP LEFT</div>
</div>

<div class="container">
  <div class="hideCorner top-right"></div>
  <div class="contentsTop">TOP RIGHT</div>
  <div class="contentsBottom">TOP RIGHT</div>
</div>

<div class="container">
  <div class="hideCorner bottom-left"></div>
  <div class="contentsTop">BOTTOM LEFT</div>
  <div class="contentsBottom">BOTTOM LEFT</div>
</div>

<div class="container">
  <div class="hideCorner bottom-right"></div>
  <div class="contentsTop">BOTTOM RIGHT</div>
  <div class="contentsBottom">BOTTOM RIGHT</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

Is there a way to alter the footer across all my pages using just one document?

I'm having trouble coming up with a title for my question, so please bear with me. I am working on a Bootstrap website and I want to create a consistent navbar and footer across all pages without duplicating the code in each document. How can I achiev ...

SASS malfunctioning, error messages popping up in command prompt while running gulp serve

As I develop a web app using AngularJS and Gulp, I encounter an issue where the CSS does not seem to work when running 'gulp serve'. Despite attempting to reinstall various components like node_modules, Node.js, and Gulp, the same error persists. ...

Organizing CSS DIV code by sections for desktops and mobile devices

My CSS file contains properties that are common for both PC and cellphone browsing, but some vary between the two platforms. I utilize @media screen and (max-width: X px) to handle this, with one set of rules for narrow screens and another for wider screen ...

I am having an issue with my DIV not functioning correctly in conjunction with my JS animation. What modifications should I make to

I have a simple JS animation script that fetches data from the <div class="quiz"> Some content </div> for animation. When I include this script in my HTML, the animation and other functions such as previous and next work properly. See ...

Is the bootstrap navigation bar always hogging up valuable space?

Currently, I am diving into the world of react while also incorporating bootstrap styles. My current project involves creating a navigation bar using bootstrap, however, I'm facing an issue where the navbar is displaying in the middle rather than wher ...

Within an HTML document, select one checkbox out of two checkboxes without utilizing JQuery

Is there a way to select only one checkbox out of two? I know it can be done easily using Jquery, but is there a default option in HTML for this as well? I have exactly 2 checkboxes. Thank you. code: <input type="checkbox" value="1" name="foo" /> ...

Steps for positioning a play button at the center of all images

index.html - here is the index.html file code containing all the necessary html code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width ...

The CSS method for changing the content URL is experiencing difficulties in Firefox

Css: .woocommerce-placeholder.wp-post-image { content: url("DSC0926-1.jpg"); } /*for firefox*/ .woocommerce-placeholder.wp-post-image::before { content: url("DSC0926-1.jpg"); } HTML <img src="placeholder.png" alt="Placeholder" class="woocomm ...

Struggling with aligning buttons in a horizontal navigation bar

I have been struggling to center the buttons on my navigation bar for quite some time now, despite my efforts searching through Google (I'm still a beginner in CSS). Below is the code I have for the navbar (excluding my numerous unsuccessful attempts ...

"Deleting a line from a text file in PHP with a predetermined format: A step-by-step guide

I am facing a situation where I need to manipulate a CSS file through PHP. The CSS file contains the following properties: #firstdiv { width:100%; height:200px; } #seconddiv { width:80%; height:70px; } #thirddiv { width:80%; height:70px; } #firstdiv { col ...

Limit the radius to only apply on big screens using tailwind css

Is there a way to apply border radius to an image only on larger screens and maintain straight edges on smaller screens? I'm working with Nextjs and Tailwind CSS. ...

Tips for changing the size and color of SVG images in a NextJS application

Looking to customize the color and size of an svg image named "headset.svg". Prior to this, I used next/image: <Image src={'/headset.svg'} alt='logo' width={30} height={30} className='object-contain' /> The s ...

Tips for centering text in a dijitTextBox:

Ensure that the text is centered vertically with left padding and placeholder text included Check out the image link below: https://i.stack.imgur.com/PbHDa.jpg Snippet of my xPage code: <xe:djTextBox id="djTextBoxSearch" style="width:100%;height: ...

adding content to div is becoming less speedy

Currently, I'm developing a drawing board using only html/css/jquery and the drawing functionality is working smoothly. The approach I've taken involves capturing the mousemove events and placing a dot (div) at each point where the event occurs, ...

The latest bug fix and update in Bootstrap 4.5.2 now includes an updated version of Popper.js. Make sure to use the

Hello fellow developers, I am currently working with npm bootstrap version 4.5.2 and above. However, I am facing an issue with the compatibility of @popperjs/core. If anyone can assist me in resolving the bootstrap.js error temporarily, specifically re ...

When the user is actively scrolling in the browser, the button will disappear. However, once the scrolling action is completed, the button will gradually fade

Is there a way to hide the button with the id #stats while the user is scrolling, and then have it fade back in once they finish scrolling? It seems like the code below is not working as expected. Any help would be greatly appreciated! <button id="st ...

How can you determine whether the CSS of a <div> is defined in a class or an id using JavaScript/jQuery?

Hey there, I'm currently working on dynamically changing the CSS of a website. Let's say we have a div like this: <div id="fooid" class="fooclass" ></div> The div has a class "fooclass" and an ID "fooid", and we're getting its ...

Reducing the slide margins in impress.js?

When using Impress.js, I noticed that the default slides have a large left margin (or padding - it's hard to determine with Firefox's Inspector). I have a slide with a wide <pre> block that would fit if it were aligned to the left, but it d ...

Using array map to create a centered table in a React web application

In my React project, I created a table using the array.map function. However, I'm facing an issue where the output of array.map is always aligned to the left, even before the table itself. I want to center the entire table. JSX: <div className=&qu ...

The absence of an eye icon in the password field when using bootstrap 5

I'm having trouble positioning the eyeball icon to the right side of my form when using Bootstrap v5 and FontAwesome v5. Instead, the password field is being shifted further to the right compared to the username field, and the eye icon is not displayi ...