1

can you help me to make like this div:

My Code:

body{
        display: flex;
        justify-content: center;
      }
      #talkbubble {
      width: 160px;
      height: 80px;
      background: #bc0a14;
      position: relative;
      -moz-border-radius: 10px;
      -webkit-border-radius: 10px;
      border-radius: 10px;
    }
    #talkbubble:before {
      content: "";
      position: absolute;
      right: 100%;
      top: 26px;
      width: 0;
      height: 0;
      border-top: 13px solid transparent;
      border-right: 26px solid #bc0a14;
      border-bottom: 13px solid transparent;
    }
    #talkbubble:after {
      content: "";
      position: absolute;
      left: 100%;
      top: 26px;
      width: 0;
      height: 0;
      border-top: 13px solid transparent;
      border-left: 26px solid #bc0a14;
      border-bottom: 13px solid transparent;
    }
<div id="talkbubble"></div>

I want to create this div with the same style in the image

0

2 Answers 2

4

here is an idea with pseudo element and radial-gradient. I used CSS variable to easily adjust the shape but it's not mandatory

.box {
  width: 100px;
  height: 50px;
  margin:0 var(--w,20px);
  display:inline-block;
  border-radius: 15px;
  background: var(--c,red);
  position: relative;
}

.box:before,
.box:after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--w,20px);
  right:calc(100% - 2px);
  background:
   radial-gradient(107% 100% at top    left,transparent 96%,var(--c,red) 100%) top, 
   radial-gradient(107% 100% at bottom left,transparent 96%,var(--c,red) 100%) bottom;
  background-size:100% 50.1%;
  background-repeat:no-repeat;
}
.box:after {
  left:calc(100% - 2px);
  right:auto;
  transform:scaleX(-1);
}
<div class="box"></div>

<div class="box" style="--c:blue;--w:30px;"></div>

<div class="box" style="--c:purple;--w:10px;height:60px"></div>

Sign up to request clarification or add additional context in comments.

Comments

0

please try this code:

body{
        display: flex;
        justify-content: center;
      }
      #talkbubble {
         width: 180px;
    height: 54px;
    background: #bc0a14;
    position: relative;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    border-radius: 24px;
    }
    #talkbubble:before {
          content: "";
    position: absolute;
    right: 99%;
    top: 17px;
    width: 0px;
    height: 1px;
    border-top: 9px solid transparent;
    border-right: 10px solid #bc0a14;
    border-bottom: 9px solid transparent;
    }
    #talkbubble:after {
      content: "";
    position: absolute;
    left: 99%;
    top: 17px;
    width: 0;
    height: 1px;
    border-top: 9px solid transparent;
    border-left: 10px solid #bc0a14;
    border-bottom: 9px solid transparent;
    }
<div id="talkbubble"></div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.