How to Cover parent class gradient color on psuedo class(before and after) using css?

Viewed 34

"How to Cover parent class gradient color on pseudo class(before and after) using css? i trying to create some arrows in my web pages,and i suing the div and div 'after' class.The div background-color is linear gradient and i apply the same color on 'after' class. But the result is two different shapes, below i attached my code.

.test div {
  display: inline-block;
  position: relative;
  height: 40px;
  line-height: 25px;
  padding: 0 15px 0px 25px;
  border: 1px solid transparent;
  background: #16a0e3;
  float: left;
  display: flex;
  margin: 2px 2px 2px 0px;
  width: 150px;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.test .hzmenu {
  background: linear-gradient(45deg, black, transparent);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 11px;
  font-weight: normal;
  text-transform: uppercase;
  transform-style: preserve-3d;
}

.test .hzmenu a:after {
  background: linear-gradient(45deg, black, transparent);
}

.test div a:after {
  content: '';
  border-top: 1px solid #ccc;
  border-right: 1px solid #ccc;
  width: 29px;
  height: 29px;
  position: absolute;
  right: -6px;
  top: 1px;
  z-index: 1;
  -webkit-transform: translate(11px, 4px) rotate(45deg);
  transform: translate(11px, 4px) rotate(45deg);
}
<div class="test">
  <div class="hzmenu">
    <a href="#">
            Menu1
        </a>
  </div>
</div>

1 Answers

Hi @Ranjith Please find your css for :after :

.test div a:after {
content: '';
border-top: 20px solid transparent;
border-right: 30px solid #2b2b2b;
border-bottom: 20px solid transparent;
position: absolute;
right: 0;
top: 0;
z-index: 1; }

You will not get Gradient on your Half Arrow but you will get your desired reult

Related