鼠标离开时输入搜索将文本颜色更改为黑色

时间:2014-03-30 15:08:35

标签: html css css3

我正在尝试开发一个搜索输入,但我遇到了问题而我找不到解决问题的方法。

我已经有输入搜索工作,当我点击它扩展的输入时,但当输入扩展然后我写,我写白色的文字,我想要这样。

但是当我在外面点击时,输入文字的颜色是黑色,我也希望它是白色或灰色。

有谁知道我们如何用CSS做到这一点?鼠标离开时颜色是白色而不是黑色?

我的codePen文件:

http://codepen.io/mib/pen/saytl/

我的HTML

 <li id="sb-search" style="float:right; list-style:none; height:20px;">
     <form id="search">                   
       <input name="q" type="text" size="40" placeholder="Pesquisar..." />             
      </form>
 </li>

我的CSS:

#search input[type="text"] {
    border: 0 none;
    font:  12px 'bariol_boldbold';
    background: #141d22;
        text-indent: 0;
    width:110px;
    padding: 6px 15px 6px 35px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); 
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    }

#search input[type="text"]:focus {
    background: #141d22;
    color: #fff;
    width: 170px;
        outline:none;
        color:000;
    -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
    }

2 个答案:

答案 0 :(得分:1)

color:#ffffff添加到#search input[type="text"],当鼠标在css中留下选择器时,颜色将为白色。

See demo

答案 1 :(得分:1)

为输入添加白色

相关问题