Skip to content Skip to sidebar Skip to footer

Skew Only One Side Of Before & After To Get Flat-arrow

I've created some dummy breadcrumb-steps. The 1st breadcrumb-step need to have a normal flat border on the left, which is done. And on hover, I need to show the black border for ea

Solution 1:

You can adjust the transform-origin then hide the overflowing part of the skewed element and change the left border of the first child on hover:

body {
  margin: 0;
}

.breadcrumbs {
  background-color: white;
  width: 100%;
  padding: 01rem;
  font-size: 0;
  margin: 1rem;
}

.breadcrumbs.breadcrumb-step {
  display: inline-block;
  width: 12.33%;
  height: 5rem;
  text-decoration: none;
  color: black;
}
/*added this*/.breadcrumbs.breadcrumb-step:first-child {
  width: 15.33%; 
  overflow:hidden;
  border-left:1px solid lightgrey;
}
/**/.step-title {
  display: none;
}

.breadcrumb-step:before,
.breadcrumb-step:after {
  content: '';
  display: block;
  height: 50%;
  box-sizing:border-box;
  width: 100%;
  border: 1px solid lightgrey;

}
.breadcrumb-step:before {
  transform: skew(30deg);
  transform-origin:rightbottom; /*added this*/border-bottom: none;
}

.breadcrumb-step:after {
  transform: skew(-30deg);
  transform-origin:righttop; /*added this*/border-top: none;
}

/*added this*/.breadcrumb-step:hover:before,
.breadcrumb-step:hover:after,
.breadcrumbs.breadcrumb-step:first-child:hover{
  border-color: black;
}
<divclass="breadcrumbs"><aclass="breadcrumb-step"href="#"><spanclass="step-title">Home</span></a><aclass="breadcrumb-step"href="#"><spanclass="step-title">About</span></a><aclass="breadcrumb-step"href="#"><spanclass="step-title">Contact Us</span></a></div>

Post a Comment for "Skew Only One Side Of Before & After To Get Flat-arrow"