提取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:

.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 @ 2012-07-06 09:41  Lyon.L  阅读(2461)  评论(0编辑  收藏  举报