如何给输入边框左右小长度 [英] how to give input border left and right small length

查看:43
本文介绍了如何给输入边框左右小长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示输入字段,并且需要给边框下,左和右.但是在这里,我只希望左侧和右侧的边框很小.

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.

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

<input class="solid">

推荐答案

在这里.我必须在输入字段之外添加div元素,才能使用before和after选择器.

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>

这篇关于如何给输入边框左右小长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆