切换为不分页显示
【首页】 【建站杂谈】 主题:CSS美化的漂亮搜索框
字体:    回复
CSS美化的漂亮搜索框 
江南雨(2009-8-11 8:26:25)  点击:12525  回复:0  IP:121.24.168.*
CSS+javascript共同完成的一个漂亮搜索框,样式主要是CSS的功能,点击动作是由Js完成的,整体效果很棒,用到有一张背景图片,代码里有地址,复制到地址栏可下载图片。

程序代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS美化的漂亮搜索框</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style type="text/css">
<!--
.search{
padding-right:10px;
padding-left:10px;
padding-top:5px;
padding-bottom:5px;
width: 280px;
background:#1A93CC;
float:left;
position:relative;
}
.search .input{
padding-top:2px;
height:16px;
width: 180px;
border: 1px solid #0086C6;
font-size:14px;
background:#fff url(http://www.codefans.net/jscss/demoimg/200908/search_btn.gif) no-repeat right 0;
}
.label{
color:#ccc;
position:absolute;
left:12px;top:6px;
display:block;
height:22px;
line-height:22px;
font-size:12px;
}
span.submit{
cursor:pointer;
position:absolute;
left:171px;
top:6px;
width:20px;
height:20px;
text-indent:-999em;
}
-->
</style>
</head>
<body>
<div class="search">
  <form action="" method="post" name="search" id="search">
    <input name="keyword" type="text" class="input" id="keyword" value="" style="float:left;">
    <label for="keyword" id="for-keyword" class="label">我要搜索</label>
    <span class="submit" onclick="return formSubmit('frmsearch');">搜索</span>
  </form>
</div>
<script type="text/javascript">
var $ = function(id){return document.getElementById(id);}
var formSubmit = function(id){
document.forms[id].submit();
return false;
}
var tip = function(q, for_q){
q = $(q);
for_q = $(for_q);
q.onfocus = function(){
for_q.style.display = 'none';
q.style.backgroundPosition = "right -17px";
}
q.onblur = function(){
if(!this.value) for_q.style.display = 'block';
q.style.backgroundPosition = "right 0";
}
for_q.onclick = function(){
this.style.display = 'none';
q.focus();
}
};
tip('keyword','for-keyword');
</script>
</body>
</html>

[返回]
[本主题共0回复 | 每页显示20回复]
 返回列表 跳至页首跳至页尾 放大字体 缩小字体
按用户名:    按标题:   按内容:       包括所有回复
【首页】→ 【建站杂谈】 回复:CSS美化的漂亮搜索框
帖子标题:
   未登录!    

您的权限:
发表回复:×
UBB功能:×
文件上传:×
 
风格选择:极速  古韵  宽屏  大字  |  图示说明: 24小时新发主题  最近被编辑的主题  超过24小时普通主题
页面执行时间:156.25毫秒 | 在线:3 今日:188 合计:3234850 | 清除COOKIE |