1

I have an arrow-like shape created with CSS only. I want to apply a border to it and if possible, a box-shadow as well. I've tried following this answer, but it won't work. I also wonder if there's a way to make the left white triangle (the one that gives the arrow the shape) transparent instead of white.

This is what I'm trying to achieve: enter image description here

This is what I have. As you can see, I'm only missing the border and shadow:

enter image description here

.box {
  width: 180px;
  height: 30px;
  background: -webkit-linear-gradient(-211.23000000000002deg, #B07537 0, #F0B971 100%);
  background: -moz-linear-gradient(301.23deg, #B07537 0, #F0B971 100%);
  background: linear-gradient(301.23deg, #B07537 0, #F0B971 100%);
  text-align: center;
  color: #fff;
  position: absolute;
  display: table;
  z-index: 1;
  top: 20px;
  right: 7px;
  filter: drop-shadow(0px 3px 4px rgba(0, 0, 0, 0.25));
}

.box span {
  display: table-cell;
  vertical-align: middle;
  font-size: 1em;
  font-weight: 500;
}

.box:before {
  content: '';
  position: absolute;
  border-left: 15px solid white;
  border-top: 15px solid transparent;
  border-bottom: 17px solid transparent;
  left: 0px;
  top: 0px;
  width: 0;
  height: 0;
  display: block;
}
<div class="box">
  <span>Text</span>
</div>
Paula
  • 477
  • 6
  • 20

1 Answers1

0

That is the closest thing which I can achieve with pure css. I hope it can help you at least a little bit. Let me know it does.

.box{
  font-size:20px;
  position:relative;
  display:inline-block;
  margin:5em;
  text-align:center;
  filter: drop-shadow(0px 3px 4px rgba(0, 0, 0, 0.5));
}

.arrow {
  height: 30px;
  display:inline;
  position:relative;
}

.content{
  display:inline-block;
  padding: 0.7em 1em 0.5em;
  min-width: 10em;
  background: linear-gradient(270deg, #B07537 0, #F0B971 100%);
  position:relative;
  color: white;
  font-weight: 500;
}

.box:before,
.box:after,
.arrow:before,
.arrow:after {
  content:'';
  position:absolute;
  border-style:solid;
}

.arrow:before {
  top: -0.2em;
  bottom: 0;
  left:-1.85em;
  margin: auto;
  border-width: 1.4em 1em 1.4em 1.15em;
  border-color: #fccc4f #fccc4f #fccc4f transparent;
  z-index:-1;
}

.arrow:after {
  left:-1.5em;
  margin: auto;
  border-width: 1.2em 1em 1.2em 1em;
  border-color: #F0B971 #F0B971 #F0B971 transparent ;
  z-index:-1;
}

.box:before{
  top: -0.15em;
  bottom: -0.15em;
  left:0;
  right: 0;
  margin: auto;
  border-width: 1.4em 1em 1.4em 1.15em;
  border-color: #fccc4f #fccc4f #fccc4f transparent;
  z-index:-1;
}

.box:after{
  bottom: -.6em; 
  right:0;
  border-width: 0 0 .4em .7em;
  border-color:  gray transparent transparent gray ;
}

.text {
  margin-left: -2em;
  line-height: 1;
  letter-spacing: 2px;
  font-weight: bold;
}

/* .text:before{
  top:100%; left:0;
  border-width: .5em 2em 0 0;
  border-color: #FC9544 transparent transparent transparent;
} */
<div class="box">
  <div class="arrow"></div>
  <div class="content">
    <span class="text">Text</span>
    </div>
</div>
Kishieel
  • 1,811
  • 2
  • 10
  • 19