VK Chikkadamalla VK Chikkadamalla - 8 days ago 6
CSS Question

how to give input border left and right small length

I need to display the input field and i need give border bottom , left and right. But here i want only small portion border left side and right side.

enter image description here



.solid {
border-style: solid;
border-left-style: dashed;
border-top: none;
border-right-style: dashed;
}

<input class="solid">




Answer

Here you go. I had to add a div element outside the input field to use the before and after selectors.

.field {
  position: relative;
  display: inline-block;
}
.solid {
  border: none;
  border-bottom: 2px solid #000;
  padding: 5px;
}
.solid:focus {
  outline: none;
}
.field::after {
  content: '';
  width: 2px;
  height: 10px;
  position: absolute;
  background: #000;
  bottom: 0;
  right: 0;
}
.field::before {
  content: '';
  width: 2px;
  height: 10px;
  position: absolute;
  background: #000;
  bottom: 0;
  left: 0;
  z-index: 1;
}
<div class="field">
  <input class="solid" type="text">
</div>