2012-01-06 32 views
1

我想用“输入错误”造型 为出现在这里: http://twitter.github.com/bootstrap/不能使用Twitter bootsrap的错误样式

,并在其后一个自定义的CSS只

(相关行是722

form .clearfix.error > label, form .clearfix.error .help-block, form .clearfix.error .help-inline { 
    color: #b94a48; 
} 

我的标记:

<div id="new_folder_name_div" class="clearfix error"> 
        <label for="new_folder_name">Name&nbsp</label> 
        <div class="input"> 
         <input class="medium error" id="folder_name" size="15" type="text" /> 
         <span>*</span> 
        </div> 

一种图像:

enter image description here

但我铬控制台输入元件不与上述的CSS作用匹配看到。

任何想法为什么?

回答

2

实际输入是下一行。请注意,包含class“clearfix error”的包含div是必需的。

form .clearfix.error input, form .clearfix.error textarea { 
    color: #B94A48; 
    border-color: #EE5F5B; 
} 

<div class="clearfix error"> 
    <div class="input"> 
     <input class="xlarge error" type="text"> 
    </div> 
</div> 
+0

得到了bootsrap.css原样。仍然没有用红色给我的输入着色 – 2012-01-07 00:00:51

+1

你的输入需要在表单内,是吗?工作正常:http://jsfiddle.net/QHNFr/2/ – spike 2012-01-07 00:38:04

+0

btw,你如何添加资源jsfiddle哪些不在线?你在哪里举办他们? – 2012-01-07 14:43:37

0

尝试使用

$('#folder_name').closest('.clearfix error').addClass('error');