What is the best way to create a shape using CSS?

In my chat application, I have a functionality where replies on a chat are initially hidden and represented by a count in a red box. When the user clicks on the red button, the replies from other users are revealed along with an input box for writing a reply, all enclosed within a blue box. Can anyone guide me on how to create this design using CSS?

Answer №1

Check out this example on FIDDLE.

Take some time to experiment with the CSS settings in the top right corner and observe the changes.

Cascading Style Sheets (CSS)

.holder {
    width: 500px;
    height: 400px;
    border: 0px solid black;
}
.upper {
    height: 30%;
    border: 0px solid red;
}
.littleblue {
    height: 100%;
    width: 35%;
    background-color: blue;
    border-radius: 20px 20px 0px 0px;
    float: right;
}
.littlered {
    width: 90%;
    height: 40px;
    background-color: red;
    margin: 10px auto;
    border-radius: 20px;
}
.lower {
    height: 70%;
    background-color: blue;
    border-radius: 20px 0px 20px 20px;
    border: 0px solid green;
}

Answer №2

Essentially, this code snippet demonstrates a simple layout using a form with two fieldsets:

<div>
  <form>
    <fieldset class="right">
      <button>button</button>
        </fieldset>
    <fieldset>
    </fieldset>
  </form>
</div>
div {
  width:50%;
  margin:auto;
}
fieldset {
    background:blue;
  clear : right;
  height:100px;  /* remove height once content is added */
  border:none;
    border-radius:1em  0 1em 1em;
}
.right {
  float:right;
  border-radius:1em  1em 0 0;
  height:50px;/* remove height once content is added */
  position:relative;/* to set pseudo element where desired */
}
.right:after{
  content:'';
  height:2em;/* use twice the value for radius */
  width:2em;
  position:absolute;
  left:-2em;
  bottom:0;
  border-radius:2em;
  box-shadow: 23px 23px 0 10px blue;/* drop shadow creating inside round corner effect */
  z-index:-1;
}

Check out the demo on CodePen

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

Executing a nested function as an Onclick event in an HTML document

I am currently working on a project within the Phone Gap framework where I need to transfer values from one HTML page to another. My solution involved using the code snippet below. var searchString = window.location.search.substring(1),i, val, params = s ...

Enhance your website with Bootstrap 4 by separating text and images in your carousel

I've been struggling to create a slider similar to the one shown in the image. I attempted using the Bootstrap carousel, but ran into issues with inconsistent image sizes and the text on the left side jumping around before settling in its correct posi ...

Can this layout be achieved using DIV elements?

Struggling to create a unique HTML/CSS layout that extends beyond the center? Imagine a standard horizontally centered page, but with one div expanding all the way to the right edge of the browser window. This design should seamlessly adjust to window res ...

JavaScript failing to load following PHP header() redirect

I've set up a page that allows users to sign in by filling out a basic form, which then sends the data to a separate PHP script for validation. After the validation process is complete, the PHP script uses the header() function to redirect the user to ...

``Sorry, the link redirection feature is currently experiencing technical

First and foremost, take a look at this example View here Based on the example provided, I would like to create a similar page using the Telrik Text Editor, with a list of links and their corresponding paragraphs. Here is the HTML I am using in the Telr ...

Words placed in the middle of the picture

<div> <img style="vertical-align:middle" src="https://placehold.it/60x60"> <span style="">New Product</span> </div> I require this specific layout to be responsive. Could you please provide instructions on achieving this? ...

Adjust the height of the card body to match the horizontal bootstrap 5 card image

Is there a way to use Bootstrap 5.1.3 to make the image fill the height of the card's body and footer, while also ensuring the card-footer is placed at the bottom of the card? The desired outcome: <link rel="stylesheet" href="https://cdn.jsdeli ...

Struggling to remove the image tag from the jQuery ajax response

My web app is designed to send an ajax post request to a PHP script, which then returns a chunk of HTML data. This HTML includes an image and a table of information. The challenge I'm facing is how to extract the image from the rest of the HTML so tha ...

The class name feature on the Drawer component is malfunctioning

React and material-ui are my tools of choice, but I've hit a roadblock. I'm attempting to define some custom CSS behavior for the drawer component, using the className property as recommended. However, despite following the instructions, it' ...

`Ensuring uniform height for card titles`

So here's the scenario I'm dealing with: https://i.sstatic.net/4f7AR.png There seems to be an issue with alignment in the dark blue boxes when they are displayed in a flex container. The top box is not aligned properly with the one next to it. ...

Evaluating QUnit Test Cases

How do you write a test method in QUnit for validating functions developed for a form? For example, let's consider a form where the name field should not be left blank. If the validation function looks like this: function validNameCheck(form) { if ...

The Bootstrap 3.3 Carousel is stationary and does not rotate

I am facing a challenge with implementing a Carousel using Bootstrap version 3.3.7 on my website. The code snippet is as follows: <!-- Carousel ================================================== --> <div class="row dark-start d-none d-lg-block"&g ...

Column Alignment Problem in Bootstrap

I'm currently working on a blog template project that resembles the design of this particular page However, I've encountered an issue with aligning the grids in a way that meets my requirements. To showcase my problem, I have shared my version o ...

Error loading custom Javascript in MVC 4 view during the first page load

I'm working on an MVC 4 application that utilizes jQuery Mobile. I have my own .JS file where all the functionality is stored. However, when I navigate to a specific view and check the page source, I notice that all scripts files are loaded except fo ...

Looking to automate the scraping of Wikipedia info boxes and displaying the data using Python for any Wikipedia page?

My current project involves automating the extraction and printing of infobox data from Wikipedia pages. For example, I am currently working on scraping the Star Trek Wikipedia page (https://en.wikipedia.org/wiki/Star_Trek) to extract the infobox section d ...

"Enhance Your Slide Up/Down Menu with a Unique Hover Effect in jQuery

HTML: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="navigation_desktop"> <div class="button_desktop_01">1.0 Main Menu <div class="SlideItem ...

The height of the <div> element is not increasing along with the content inside. If I set the height to "auto

I encountered an issue with my webpage design. It has set dimensions with blue borders on the sides and bottom. The problem arises when I add Facebook comments to the page - as more comments are added, they extend beyond the bottom of the webpage, below ...

Tips for disabling autofocus on textarea when it is initially created in Internet Explorer browser

By clicking a button, I can generate a new <textarea></textarea>. However, in Internet Explorer, the cursor automatically moves to the newly created text area. Is there a way to prevent this from happening? ...

Issue resolved: Mysterious fix found for background images not displaying in NextJS React components

I am having trouble displaying a background image on an element in NextJs using Typescript and Tailwind. I do not believe it is a TypeScript issue since I am not receiving any errors or IntelliSense warnings. Below is the code I am working with: var classn ...

Ways to position an element at the edge of the browser either on the left or right side when the image is not in a centered container

Looking to create a unique layout that involves: Utilizing a three-column structure Incorporating a div element that spans two columns Positioning an image within the two-column div so that it extends to the left edge of the browser window while staying ...