0

I wanted to remove inner border or box from the box, as shown below

below image:

Note: if possible i want to retain my code with bit addition

Note2: i don't want to remove box-shadow on element or :after

enter image description here

here is my codepen:https://codepen.io/anon/pen/wEwgRR

#messagebox,#messagebox2{
  width:400px;
  height:150px;
  background:red;
  margin: 0 auto;
  position:relative;
  color:#fff;
  padding:12px;
  font-size:18px;
  border-radius:3%;
  box-shadow:0px 8px 9px black;
  margin-top:80px;
}

#messagebox:after{
  content:'';
  position:absolute;
  width:50px;
  height:50px;
  background:red;
  bottom:-25px;
  right:65%;
  transform: rotate(45deg);
  color:#fff;
  box-shadow:0px 5px 9px black;
}

#messagebox2:after{
  content:'';
  position:absolute;
  width:50px;
  height:50px;
  background:yellow;
  bottom:-25px;
  right:65%;
  transform: rotate(45deg);
  color:#fff;
  box-shadow:0px 5px 9px black;
}
<div id="messagebox">
   hello world
</div>

<div id="messagebox2">
   hello world
</div>

Please help me thanks in advance !!!!

Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95

2 Answers2

2
  • Create another layer using ::before pseudo element of same width / height as parent.
  • Apply shadow on this layer instead of parent element.
  • Add some negative z-index value to place it below the ::after pseudo element i.e arrow.

Demo:

.messagebox {
  width:400px;
  height:150px;
  background:red;
  margin: 0 auto;
  position:relative;
  color:#fff;
  padding:12px;
  font-size:18px;
  margin-top:80px;
}

.messagebox::before {
  box-shadow:0px 8px 9px black;
  position: absolute;
  border-radius:3%;
  content: '';
  z-index: -2;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
}

.messagebox:after{
  content:'';
  position:absolute;
  width:50px;
  height:50px;
  background:red;
  bottom:-25px;
  right:65%;
  z-index: -1;
  transform: rotate(45deg);
  color:#fff;
  box-shadow:0px 5px 9px black;
}

.messagebox2:after{
  content:'';
  position:absolute;
  width:50px;
  height:50px;
  background:yellow;
  bottom:-25px;
  right:65%;
  transform: rotate(45deg);
  color:#fff;
  box-shadow:0px 5px 9px black;
}
<div class="messagebox">
   hello world
</div>

<div class="messagebox messagebox2">
   hello world
</div>
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
0

Try this out

.messagebox {
  background: red;
  border-radius: 12px;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 1);
  box-sizing: border-box;
  color: white;
  height: 150px;
  margin: 20px auto;
  max-width: 400px;
  padding: 16px;
  position: relative;
}

.messagebox:after {
  border: 16px solid black;
  border-color: transparent transparent red red;
  bottom: -30px;
  box-shadow: -4px 4px 4px 0 rgba(0, 0, 0, 1);
  box-sizing: border-box;
  content: "";
  height: 0;
  left: 50%;
  margin-left: -16px;
  position: absolute;
  transform: rotate(-45deg);
  transform-origin: 0 0;
  width: 0;
}
<div class="messagebox">Hello World!</div>
dysfunc
  • 2,008
  • 1
  • 13
  • 15