[转]Add Bootstrap Glyphicon to Input Box
本文转自:http://stackoverflow.com/questions/18838964/add-bootstrap-glyphicon-to-input-box
How can I add a glyphicon to a text type input box? For example I want to have 'icon-user' in a username input, something like this:

|
576down voteaccepted
|
Without Bootstrap:We'll get to Bootstrap in a second, but here's the fundamental CSS concepts in play in order to do this yourself. As beard of prey points out, you can do this with CSS by absolutely positioning the icon inside of the input element. Then add padding to either side so the text doesn't overlap with the icon. So for the following HTML:
You can use the following CSS to left and right align glyphs:
Demo in Plunker
With Bootstrap:As buffer points out, this can be accomplished natively within Bootstrap by using Validation States with Optional Icons. This is done by giving the The simplest example would be something like this:
Pros:
Cons:
To overcome the cons, I put together this pull-request with changes to support left aligned icons. As it is a relatively large change, it has been put off until a future release, but if you need these features today, here's a simple implementation guide: If you're using less, just include these changes in your project. If you're not using less, grab the file and convert it to CSS with any online LESS Compiler. Then, all you have to do is include the class Since there are a lot of possible html configurations over different form types, different control sizes, different icon sets, and different label visibilities, I created a test page that shows the correct set of HTML for each permutation along with a live demo. Here's a demo in Plunker
Didn't find what you were looking for? Try these similar questions: |
[转]Add Bootstrap Glyphicon to Input Box的更多相关文章
- 实现bootstrap布局的input输入框中的图标点击功能
使用bootstrap布局可以在input的输入框中添加譬如登录名输入框中的一键清除图标和密码输入框中显示密码的小眼睛图标.如下图: 但是在将图标放入input输入框中,这些小图标是无法获得点击事件的 ...
- bootstrap glyphicon图标无法显示
如果不注意bootstrap引入css和fonts的规范,则可能会导致bootstrap 在显示glyphicon图标时无法正常显示,显示为方框. 此时可搜索bootstrap.css中的.glyph ...
- [转]How to Add Bootstrap to an Angular CLI project
本文转自:https://loiane.com/2017/08/how-to-add-bootstrap-to-an-angular-cli-project/ In this article we w ...
- bootstrap模态框input不能获取焦点并编辑【转】
Bootstrap模态框时input标签[日期控件也有这样的问题]不能编辑的问题,下面是我的解决方法: 1.将下图中框出来的属性删掉即可: 2.兼容火狐浏览器,笔者在火狐中还是不能编辑,去掉下图属性即 ...
- Bootstrap中关于input里file的样式更改
给input里file类型加button样式 1.在Bootstrap中input里的file类型样式很不美观,一个按钮加一段文字,还会随浏览器的不同呈现不同的样式,所以开发的时候可以将file的样式 ...
- 去除bootstrap默认的input和选中时的样式
input默认样式除border外, 还有一个阴影效果box-shadow:选中时同样有阴影效果. input,input:focus{ border: none !important; box-sh ...
- Bootstrap系列 -- 14. 表单控件输入框input
每一个表单都是由表单控件组成.离开了控件,表单就失去了意义.接下来的我们简单的来了解Bootstrap框架中表单控件的相关知识. 单行输入框,常见的文本输入框,也就是input的type属性值为tex ...
- angulajs 当input使用 bootstrap的email类型时,如果是无效的email格式,则ng-model无效的情况
当使用bootstrap的如下input时 <input type="email" ng-model="userid"> 如果输入的内容是无效的em ...
- Bootstrap 表单控件一(单行输入框input,下拉选择框select ,文本域textarea)
单行输入框,常见的文本输入框,也就是input的type属性值为text.在Bootstrap中使用input时也必须添加type类型,如果没有指定type类型,将无法得到正确的样式,因为Bootst ...
随机推荐
- C#多线程学习(五) 多线程的自动管理(定时器)
Timer类:设置一个定时器,定时执行用户指定的函数. 定时器启动后,系统将自动建立一个新的线程,执行用户指定的函数. 初始化一个Timer对象: Timer timer ...
- [NetCore学习记录]第一章.使用netcore撸个简单的增删改查
1.引言 2.解决方案各部分介绍图 3.添加数据模型 4.添加数据库上下文 5.修改配置文件 6.使用依赖关系注入容器注册数据库上下文 7.添加基架工具并执行初始迁移 1.引言 NetCore出来有一 ...
- Cntlm
SourceForge页面 作用是转发请求到代理 可以同时加上域验证信息(为各种NTLM认证?) gradle.cmd.Terminal等工具或软件可能无法或者说没有使用系统/浏览器设置的代理,因为可 ...
- Django 标签过滤器
django内置标签 autoescape 控制当前的自动转义行为.这个标记可以作为参数打开或关闭,它决定自动转义是否在块内有效.块使用endautoescape结束标记关闭. 当自动转义生效时,所有 ...
- 动态添加select的option [转载]
动态给select标签添加option,结合前人经验以及自己经验,现在总结三种方法供大家参考,一起交流学习!首先是定义的select元素://根据ID获得select元素 var mySelect = ...
- python之爬虫(三) Urllib库的基本使用
官方文档地址:https://docs.python.org/3/library/urllib.html 什么是Urllib Urllib是python内置的HTTP请求库包括以下模块urllib.r ...
- [bzoj2816][ZJOI2012]网络(LCT,splay)
传送门 题解 话说以前还真没见过用LCT只维护一条链的……好像除了树点涂色那题…… 先看一下题目规定的两个性质 对于任意节点连出去的边中,相同颜色的边不超过两条. 图中不存在同色的环,同色的环指相同颜 ...
- composer手动安装到windows
1.配置系统变量 Path 计算机->高级系统设置->环境变量->找到系统变量Path 双击 加入 ;php根目录地址:php中ext地址 如 :“;D:\phpStudy ...
- Excel的公式:锁定某个区域函数--OFFSET()
OFFSET(标识位置,偏移的行数,偏移的列数,偏移后锁定的行数,偏移后锁定的列数) 打个比方解释:在xy轴上画一个矩形 标识位置:等同于原点; 偏移的行数:矩形的起始y轴坐标; 偏移的列数:矩形的起 ...
- UDP与IP分片
一.引言  UDP是简单的面向数据报的运输层协议.UDP不提供可靠性:它负责把应用程序传给IP层的数据发送出去,不保证能导到目的地. 二.UDP首部  端口号表示发送进程和接受进程.由于IP层已经 ...

