提取Bootstrap的Prepended input样式

Bootstrap相信大家都已有所了解了,今天在做手头一个项目时,想用一下Prepended input样式,参见:http://twitter.github.com/bootstrap/base-css.html#forms,找到下面的“Prepend & append inputs”。我想将我项目中的某两个input变成如下形式:

pre

 

也就是在input前面加上几个文字。因为这是base css,所以只需要引用bootstrap.css文件即可,然而引用之后发现我页面的其他样式被修改了,比如li,比如body里的字体等等,看来bootstrap还是有一些侵略性的。改来改去半天还是不得其法,怒了。。索性将其用到的样式提取了出来,不引用bootstrap整个样式,见下:

Html:

 

CSS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.input-prepend
{
    display: inline-block;
    margin-bottom: 0;
}
 
.input-prepend .add-on, .input-append .add-on {
display: inline-block;
width: auto;
height: 14px;
min-width: 16px;
padding: 4px 5px;
font-weight: normal;
line-height: 12px;
text-align: center;
text-shadow: 0 1px 0 white;
vertical-align: middle;
background-color: #EEE;
border: 1px solid #CCC;
}
 
.input-prepend .add-on{
-webkit-border-radius: 3px 0 0 3px;
-moz-border-radius: 3px 0 0 3px;
border-radius: 3px 0 0 3px;
}
 
.input-prepend .add-on, .input-prepend .btn {
margin-right: -1px;
}
 
.input-prepend input[type="text"]{
position: relative;
margin-bottom: 0;
vertical-align: middle;
background-color: white;
border: 1px solid #CCC;
-webkit-border-radius: 0 3px 3px 0;
-moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
-ms-transition: border linear 0.2s, box-shadow linear 0.2s;
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
transition: border linear 0.2s, box-shadow linear 0.2s;
}
.input-prepend input[type="text"]{
display: inline-block;
height: 14px;
padding: 4px;
margin-bottom: 0px;
font-size: 13px;
line-height: 14px;
color: #555;
width:200px;
}

并且根据我自己的需要,我调整了input的高度,line-height等样式,最终效果如下:

demo

posted @   Lyon.L  阅读(2467)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示