简体   繁体   English

输入栏自定义

[英]Input field with customization

I would like to add the green label to the input field like the following picture. 我想将绿色标签添加到输入字段,如下图所示。 It is one day I am trying different methods but I could not do it yet. 有一天,我正在尝试不同的方法,但目前还无法完成。 any ideas!!! 有任何想法吗!!!

I am using bootstrap responsive to design the page layout. 我正在使用Bootstrap响应式设计页面布局。 The shadow is okay not, only the problem is the label. 阴影不是可以的,唯一的问题是标签。

在此处输入图片说明

<div class="row-fluid">
 <div class="span12" align="center">
  <div class="row-fluid">
   <div class="span2"></div>
    <div class="span4">
        <input type="text" class="form-control" name="name" placeholder="Nome"/>
    </div>
    <div class="span4">
        <input type="text" class="form-control" name="Family" placeholder="Cognome"/>
    </div>
    <div class="span2"></div>
  </div>
 </div>
</div>

You can just add :before pseudo-element on parent div because input can not contain other elements. 您可以只在父div上的伪元素:before添加:before因为input不能包含其他元素。 Here is another Example . 这是另一个Example

 input { padding: 10px 20px; border: 1px solid #D0D1D2; box-shadow: 0px 5px 5px 0px #DAD9E0; } .element { position: relative; } .element:before { position: absolute; content: ''; width: 10px; height: 10px; background: #00E09E; top: 50%; left: 0; transform: translate(-50%, -50%); } 
 <div class="element"> <input type="text" placeholder="Some Text"> </div> 

Since you're using Bootstrap as your CSS framework, you can achieve this by customizing the input-group-addon class. 由于您将Bootstrap用作CSS框架,因此可以通过自定义input-group-addon类来实现。

Read more about it: http://getbootstrap.com/components/#input-groups 进一步了解它: http : //getbootstrap.com/components/#input-groups

HTML: HTML:

<div class="container">
  <div class="input-group">
    <span class="input-group-addon" id="basic-addon1">
      <div class="square"></div>
    </span>
    <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
  </div>
</div>

CSS: CSS:

.input-group-addon{
  border: 0px !important;
  background: transparent !important;
  position: absolute !important;
  top: 4px !important;
  left: -19px !important;
  z-index: 9999 !important;
}
.square{
  width:15px!important;
  height:15px!important;
  background: green!important;
}

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM