FeelRightz
FeelRightz

Reputation: 2979

CSS : corner cut div , filled and border

I trying to create this two corner cut div, one is filled , another is border, both with shadow.

However I facing an issue, which is for border shape corner, I unable to create border with corner cut.

I appreciate with any other idea to create this kind of filled shape and border shape.

.buttongroup {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.buttongroup .gap {
  width: 30px;
  -webkit-box-flex: 0;
      -ms-flex: none;
          flex: none;
}

.neonbutton {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  width: 100%;
  position: relative;
}

.neonbutton .l {
  width: 100%;
  height: auto;
  background-color: #37E8FC;
}

.neonbutton .r {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  width: 30px;
  -webkit-box-flex: 0;
      -ms-flex: none;
          flex: none;
}

.neonbutton .corner {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 25px 0 0 30px;
  border-color: transparent transparent transparent #37E8FC;
}

.neonbutton .square {
  height: 30px;
  width: 30px;
  background-color: #37E8FC;
}

.neonbutton .value {
  position: absolute;
  width: 100%;
  height: 100%;
  text-align: center;
  color: #000;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  font-size: 17px;
  font-weight: bold;
}

.neonbutton.outline .l {
  background-color: transparent;
  border: 2px solid #37E8FC;
  border-right: none;
}

.neonbutton.outline .corner {
  background-color: transparent;
}

.neonbutton.outline .square {
  background-color: transparent;
  border-right: 2px solid #37E8FC;
  border-bottom: 2px solid #37E8FC;
}
<div class="buttongroup">
  <div class="neonbutton">
    <div class="l"></div>
    <div class="r">
      <div class="corner"></div>
      <div class="square"></div>
    </div>
    <div class="value">Lorem</div>
  </div>
  <div class="gap"></div>
  <div class="neonbutton outline">
    <div class="l"></div>
    <div class="r">
      <div class="corner"></div>
      <div class="line"></div>
      <div class="square"></div>
    </div>
    <div class="value">Lorem</div>
  </div>
</div>

enter image description here

Upvotes: 3

Views: 266

Answers (1)

Temani Afif
Temani Afif

Reputation: 272806

I would do the first one like below:

.box {
  --c:20px; /* control the cut */
  font-size: 25px;
  padding: 10px 30px;
  display: inline-block;
  position: relative;
  z-index: 0;
  filter: drop-shadow(0 0 5px #37E8FC)
}

.box:before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: #37E8FC;
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, 0 100%);
}

body {
  background: #000;
}
<div class="box">some text</div>

And the second one:

.box {
  --b:5px;  /* control the border */
  --c:20px; /* control the cut */
  font-size: 25px;
  padding: 10px 30px;
  display: inline-block;
  position: relative;
  color:#fff;
  z-index: 0;
  filter: drop-shadow(0 0 5px #37E8FC)
}

.box:before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(to bottom left, #37E8FC 50%,#0000 50.5%) 100% 0/calc(var(--c) - 0.3*var(--b)) calc(var(--c) - 0.3*var(--b)) no-repeat;
  border:var(--b) solid #37E8FC;
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, 0 100%);
}

body {
  background: #000;
}
<div class="box">some text</div>

Upvotes: 1

Related Questions