4

I have this button that has an :after to create an arrow. I'm giving the button a box-shadow, and giving the :after a drop shadow to make the :after look like it is part of the button. However there is a tiny bit of shadow running down the left edge of the :after which makes it look disconnected from the button. See image:

enter image description here

Is there any way to get rid of the shadow running down the left edge?

The arrow is off the button below it for some reason but it doesn't matter, just try to stop the arrow's shadow running down the left edge.

Here is the code:

#go-button {
  position:relative;
  border-radius: 6px;
  height: 64px;
  text-decoration: none;
  width: 80%;
  background-color: #00BFA5;
  padding: 12px;
  border: 0px solid #Fc4747;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 200;
  z-index: 100;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); }

.bubble:after {
  content: '';
  position: absolute;
  border-style: solid;
  border-width: 15px 0 15px 24px;
  border-color: transparent #00BFA5;
  display: block;
  width: 0;
  z-index: 1;
  margin-top: -15px;
  right: -24px;
  top: 50%;
  -webkit-filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')";
  filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')"; }
<button id="go-button" type="submit" class="bubble">
  GO
</button>
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287

3 Answers3

3

You actually do want to use drop-shadow, since this is a "complex object". Move it to the parent element; you'll find the that drop-shadow is properly applied to the after pseudo-element:

#go-button {
  position:relative;
  border-radius: 6px;
  height: 64px;
  text-decoration: none;
  width: 80%;
  background-color: #00BFA5;
  padding: 12px;
  border: 0px solid #Fc4747;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 200;
  z-index: 100;
  -webkit-filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')";
  filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')";
}

.bubble:after {
  content: '';
  position: absolute;
  border-style: solid;
  border-width: 15px 0 15px 24px;
  border-color: transparent #00BFA5;
  display: block;
  width: 0;
  z-index: 1;
  margin-top: -15px;
  right: -24px;
  top: 50%;
}
<button id="go-button" type="submit" class="bubble">
  GO
</button>
chazsolo
  • 7,873
  • 1
  • 20
  • 44
1

If you haven't already used your :before for the element, you could always just hide the shadow with another pseudo element. Another option would be to offset the shadow, but that really only works well for small shadows.

An example of the first one:

#go-button {
  position:relative;
  border-radius: 6px;
  height: 64px;
  text-decoration: none;
  width: 80%;
  background-color: #00BFA5;
  padding: 12px;
  border: 0px solid #Fc4747;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 200;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  z-index: 1;
}

.bubble:after {
  content: '';
  position: absolute;
  border-style: solid;
  border-width: 15px 0 15px 24px;
  border-color: transparent #00BFA5;
  display: block;
  width: 0;
  margin-top: -15px;
  right: -24px;
  top: 50%;
  -webkit-filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  filter: drop-shadow(0px 4px 5px rgba(130, 130, 130, 0.7));
  -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')";
  filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=2, Color='#444')";
}

.bubble:before {
  display: block;
  position: absolute;
  content: '';
  right: 0;
  top: 8px;
  height: 48px;
  width: 8px;
  background: #00BFA5;
  z-index: 2;
}
<button id="go-button" type="submit" class="bubble">
  GO
</button>
Roope
  • 4,469
  • 2
  • 27
  • 51
0

The box-shadow property is probably what you want to use here. The drop-shadow is for more complex objects or SVG's.

You just need to apply a better box-shadow around the :after element.

.bubble:after {
   box-sizing: border-box;    
   border: 1em solid #00BFA5;
   border-color: transparent transparent #00BFA5 #00BFA5;
   transform-origin: 0 0;
   transform: rotate(-135deg);
   display: block;
   width: 0;
   z-index: 1;
   margin-top: -15px;
   right: -250px;
   top: 50%;
   box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
}

Since you didn't provide a working fiddle I'll leave the tweaking of the rotation and such to you, but the general idea is that you'll want to style the box-shadow after setting up a proper border & border color.

JsFiddle

leigero
  • 3,233
  • 12
  • 42
  • 63