Partial vertical borders on form input

ぐ巨炮叔叔 提交于 2020-08-20 07:15:12

问题


GOAL:
I am trying to create partial vertical borders on a form input. The desired effect is the following:

PROBLEM:
Pseudo before and after elements are not permitted for inputs so this is not an option. Alternatively, using height to limit the size of the input with border left and right cuts off the text.


LIMITS:
No extra HTML elements or images can be used, this has to work using just CSS.


POSSIBLE SOLUTIONS:
I tried to create a gradient border with limited steps but was unable to configure it for individual border sides.


CURRENT CODE:

    input[type="text"], input[type="number"], input[type="email"], textarea {
        width: 100%;
        border-radius: 0;
        padding: 0 $size-xs;
        margin: 0;
        margin-bottom: $size-m;
        text-overflow: ellipsis;
        border: 0;
        border-bottom: 1px solid $clr-darker;
        display: block;
     }

回答1:


You can go with gradient for each side like this:

input {
 border:none;
 padding:10px;
 background:
   /* Bottom side*/
   linear-gradient(#000,#000) bottom      /100% 2px ,
   /* Left side */
   linear-gradient(#000,#000) bottom left /2px 10px,
   /* Right side */
   linear-gradient(#000,#000) bottom right/2px 15px;
 background-repeat:no-repeat;
}
<input type="text" placeholder="text">


来源:https://stackoverflow.com/questions/48662420/partial-vertical-borders-on-form-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!