2013-10-07 22 views
0

所以我正在做一个搜索栏,我想知道如何让我如此,当你点击搜索栏时,它显示不同的图像,当你点击它去旧图像搜索焦点和出

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> 

现在我将不得不修改以将T他的作品

回答

0

好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/

+0

非常感谢您 –

+0

欢迎您接受这个答案,如果您发现它有用,请对其进行投票。 – 2013-10-07 01:12:46

+0

好的,我想我还是这个网站的新手 –