html - 搜索焦点和出局

标签 html css

所以我正在制作一个搜索栏,我想知道我该怎么做,当你点击搜索栏时它会显示不同的图像,当你点击它时它会转到旧图像

CSS

/***** search form *****/
#search-form {
    padding:45px 10px 0 0;
    float:right;
}
#search-form fieldset {
    position:relative; 
    width:100%; 
    display:block; 
    overflow:hidden;
}
#search-form .search-field {
    float:right;
    width:300px;
    height:34px;
    background:url(../images/search-bg.jpg) 0 0 no-repeat; 
}
#search-form input {
    width:245px; 
    font-size:14px;
    line-height:1.25em;
    padding:9px 15px 9px; 
    font-family:Arial, Helvetica, sans-serif;
    background:none;
    border:none;
    margin:0;
    outline:none;
}
#search-form .search-button {
    display:block; 
    width:20px;
    height:21px;
    text-indent:-5000px;
    background:url(../images/search-icon.png) left top no-repeat;
    position:absolute;
    right:7px;
    top:7px;
}

HTML

<form id="search-form" method="post" enctype="multipart/form-data">
   <fieldset>
      <div class="search-field">
         <input name="search" id="searchFieldBox" type="text" value="" onfocus="fieldSwap('search-bg2.png')" >
         <a class="search-button" href="#" onClick="document.getElementById('search-form').submit()"></a>   
      </div>
   </fieldset>
</form>

现在我需要编辑什么才能使它工作

最佳答案

好的,OP,我清除了您 CSS 中的一些先前声明,以免干扰添加的 CSS,这是我删除的声明:

#search-form input {background: none} and 
#search-form .search-field  {
   background:url(../images/search-bg.jpg) 0 0 no-repeat; 
}

这是更新后的 jsFiddle -> http://jsfiddle.net/WXJGy/

关于html - 搜索焦点和出局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19215576/

相关文章:

css - 更改div位置后背景不出现

html - IE7 : Nested inline elements are causing parent to act like block

CSS 在列表中添加分隔符

php - 如何使用 php 中的 session 变量将我的数据库添加到 html 表中

javascript - FullCalendar - 内联可滚动日历

PHP 未将数据插入 MySQL

html - css 停止页面

javascript - 使用 webcomponenetsjs 的 HTMLImports 以意外的执行顺序加载导入 - firefox

css - CSS 中字体开头的 @ 字符

html - IE 8(可能更早)CSS 灾难