设为首页 友情链接
在线留言 发表文章
加入收藏 广告联系

刺猬首页

| 专案技术 | 网络技术 | 图形图象 | 网络编程 | 网页设计 | 操作系统 | 服务器 | 技术白皮书 | 在线实验室 | 刺猬论坛 |
小说专版  | 数据库 | 设计赏析 | 存储频道 | 网络安全 | 私服架设 |  Solaris | 网站评估 | PC维护技巧 | 下载中心 | 博 客 |
专   题: | Linux | java | cisco | 防病毒 | 刀片 | SOA | iscsi | ASP.NET | SQL | Oracle |
您现在的位置: 刺猬宫 >> 网络编程 >> CSS >> 教程正文 用户登录 新用户注册
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
实例:在ASP.NET中创建使…
网页设计实例:利用条件…
简单实例剖析:用CSS设计…
实例讲解用CSS设置多彩的…
初学解惑:学网页制作为…
DIV CSS网页布局实例解析…
DIV CSS网页布局实例:十…
入门实例:用CSS实现hov…
实例讲解Java中的布局管…
实例讲解在JSP开发中的对…
  实例解惑:怎么做类似yahoo的搜索框?           
实例解惑:怎么做类似yahoo的搜索框?
 

  本文及代码由 renx 原创,希望能给各位网友带来帮助。

  开始

  为了做这个yahoo搜索框,我分了三步:

  1. 先做搜索分类的按钮,点击后会和其他按钮看上去比较不一样,这个是挺简单的

  <!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>search_bar</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <style>
  body,html {
  font-size:12px;
  }
  .none {display: none;}
  .block {display: block;}
  .s_c {width:800px;text-align: center;}
  .s_c ul{clear:both;margin:0;}
  .s_c li{list-style:none;float:left;position: relative;width: 70px;}
  .c_0 {padding:0px 10px 0px 10px;line-height:22px}
  .c_0 a{color:#666;text-decoration: none;}
  .c_1 {padding:4px 0;width: 70px;
  background:#0075eb;border:1px solid #054576;border-bottom-width:0;text-decoration: none;}
  .c_1 a{color:#FFF;font-weight:bold;text-decoration: none;}
  .c_2 {padding:4px 0;width: 70px;background:#a10303;border:1px solid #662626;border-bottom-width:0;}
  position: absolute;bottom: -7px;left: 0;}
  .c_3 {padding:4px 0;width: 70px;background:#B01FAA;border:1px solid #760473;border-bottom-width:0;}
  .white a {color:#FFF;font-weight:bold;text-decoration: none;}
  </style>
  <script language="javascript">
  function aa(s_id){
  for(i=1;i<4;i++){
  if(i==s_id){
  document.getElementById("m"+i).className="c_"+i+" white";
  }
  else {
  document.getElementById("m"+i).className="c_0";
  }
  }
  }
  </script>
  </head>
  <body>
  <div class="s_c"><ul>
  <li><div id="m1" class="c_1"><a href="###" onClick="aa(’1’)">分类第一</a></div></li>
  <li><div id="m2" class="c_0"><a href="###" onClick="aa(’2’)">分类第二</a></div></li>
  <li><div id="m3" class="c_0"><a href="###" onClick="aa(’3’)">分类第三</a></div></li>
  </ul>
  </div>
  </body>
  </html>

  当然这还不够,接下来实现第二步效果。

  2.加个搜索输入框,而且要能换颜色的

  <!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>search_bar</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <style>
  body,html {
  font-size:12px;
  }
  .none {display: none;}
  .block {display: block;}
  .s_c {width:800px;text-align: center;}
  .s_c ul{clear:both;margin:0;}
  .s_c li{list-style:none;float:left;position: relative;width: 70px;}
  .s_b {border:1px solid #666;}
  .s_b span{padding:20px 20px;vertical-align:middle;}
  .s_b input{margin:8px 8px;}
  .search_0 {background:#fff;}
  .search_1 {background:#d2e4fc;}
  .search_2 {background:#fcd2d2;}
  .search_3 {background:#F9D3FA;}
  .search_4 {background:#defbfb;}
  .search_5 {background:#fce8d2;}
  .search_6 {background:#FCEBB9;}
  .c_0 {padding:0px 10px 0px 10px;line-height:22px}
  .c_0 a{color:#666;text-decoration: none;}
  .c_1 {padding:4px 0;width: 70px;
  background:#0075eb;border:1px solid #054576;border-bottom-width:0;text-decoration: none;}
  .c_1 a{color:#FFF;font-weight:bold;text-decoration: none;}
  .c_2 {padding:4px 0;width: 70px;background:#a10303;border:1px solid #662626;border-bottom-width:0;}
  position: absolute;bottom: -7px;left: 0;}
  .c_3 {padding:4px 0;width: 70px;background:#B01FAA;border:1px solid #760473;border-bottom-width:0;}
  .white a {color:#FFF;font-weight:bold;text-decoration: none;}
  </style>
  <script language="javascript">
  function aa(s_id){
  for(i=1;i<4;i++){
  if(i==s_id){
  document.getElementById("s"+i).className="block be";
  document.getElementById("m"+i).className="c_"+i+" white";
  document.getElementById("uid_"+i).focus();
  }
  else {
  document.getElementById("s"+i).className="none";
  document.getElementById("m"+i).className="c_0";
  }
  }
  }
  </script>
  </head>
  <body>
  <div class="s_c"><ul>
  <li><div id="m1" class="c_1"><a href="###" onClick="aa(’1’)">分类第一</a></div></li>
  <li><div id="m2" class="c_0"><a href="###" onClick="aa(’2’)">分类第二</a></div></li>
  <li><div id="m3" class="c_0"><a href="###" onClick="aa(’3’)">分类第三</a></div></li>
  </ul>
  </div>
  <div class="s_b">
  <div class="block" id="s1"><div class="search_1"><span>Search the Web:</span><input name="uid" id="uid_1" /><span>按钮</span></div></div>
  <div class="none" id="s2"><div class="search_2"><span>Search the Web:</span><input name="uid" id="uid_2" /><span>按钮</span></div></div>
  <div class="none" id="s3"><div class="search_3"><span>Search the Web:</span><input name="uid" id="uid_3" /><span>按钮</span></div></div>
  </div>
  </body>
  </html>

  3. 现在加个箭头,做个外框,当然也要不同颜色的

  <!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>search_bar</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <style>
  body,html {
  font-size:12px;
  }
  .none {display: none;}
  .block {display: block;}
  .s_c {width:800px;text-align: center;}
  .s_c ul{clear:both;margin:0;}
  .s_c li{list-style:none;float:left;position: relative;width: 70px;}
  .s_b {border:1px solid #666;}
  .s_b span{padding:20px 20px;vertical-align:middle;}
  .s_b input{margin:8px 8px;}
  .search_0 {background:#fff;}
  .search_1 {background:#d2e4fc;}
  .search_2 {background:#fcd2d2;}
  .search_3 {background:#F9D3FA;}
  .search_4 {background:#defbfb;}
  .search_5 {background:#fce8d2;}
  .search_6 {background:#FCEBB9;}
  .c_0 {padding:0px 10px 0px 10px;line-height:22px}
  .c_0 a{color:#666;text-decoration: none;}
  .c_1 {padding:4px 0;width: 70px;
  background:#0075eb;border:1px solid #054576;border-bottom-width:0;text-decoration: none;}
  .c_1 a{color:#FFF;font-weight:bold;text-decoration: none;}
  .c_1 b{width:100%;height:11px;background:url("picture/sc1.gif") no-repeat 50% bottom;position: absolute;bottom: -7px;left: 0;}
  .c_2 {padding:4px 0;width: 70px;background:#a10303;border:1px solid #662626;border-bottom-width:0;}
  .c_2 b{width:100%;height:11px;background:url("picture/sc2.gif") no-repeat 50% bottom;
  position: absolute;bottom: -7px;left: 0;}
  .c_3 {padding:4px 0;width: 70px;background:#B01FAA;border:1px solid #760473;border-bottom-width:0;}
  .c_3 b{width:100%;height:11px;background:url("picture/sc3.gif") no-repeat 50% bottom;position: absolute;bottom: -7px;left: 0;}
  .c_4 {padding:4px 0;width: 70px;background:#41abb5;border:1px solid #297a80;border-bottom-width:0;}
  .c_4 b{width:100%;height:11px;background:url("picture/sc4.gif") no-repeat 50% bottom;position: absolute;bottom: -7px;left: 0;}
  .c_5 {padding:4px 0;width: 70px;background:#d95000;border:1px solid #96450c;border-bottom-width:0;}
  .c_5 b{width:100%;height:11px;background:url("picture/sc5.gif") no-repeat 50% bottom;position: absolute;bottom: -7px;left: 0;}
  .c_6 {padding:4px 0;width: 70px;background:#ec9e2e;border:1px solid #B28B12;border-bottom-width:0;}
  .c_6 b{width:100%;height:11px;background:url("picture/sc6.gif") no-repeat 50% bottom;position: absolute;bottom: -7px;left: 0;}
  .white a {color:#FFF;font-weight:bold;text-decoration: none;}
  </style>
  <script language="javascript">
  function aa(s_id){
  for(i=1;i<7;i++){
  if(i==s_id){
  document.getElementById("s"+i).className="block be";
  document.getElementById("m"+i).className="c_"+i+" white";
  document.getElementById("uid_"+i).focus();
  }
  else {
  document.getElementById("s"+i).className="none";
  document.getElementById("m"+i).className="c_0";
  }
  }
  }
  </script>
  </head>
  <body>
  <div class="s_c"><ul>
  <li><div id="m1" class="c_1"><a href="###" onClick="aa(’1’)"><b></b>分类第一</a></div></li>
  <li><div id="m2" class="c_0"><a href="###" onClick="aa(’2’)"><b></b>分类第二</a></div></li>
  <li><div id="m3" class="c_0"><a href="###" onClick="aa(’3’)"><b></b>分类第三</a></div></li>
  <li><div id="m4" class="c_0"><a href="###" onClick="aa(’4’)"><b></b>分类第四</a></div></li>
  <li><div id="m5" class="c_0"><a href="###" onClick="aa(’5’)"><b></b>分类第五</a></div&g

[1] [2] 下一页

频道声明:本频道的文章除部分特别声明禁止转载的专稿外,可以自由转载.但请务必注明出出处和原始作者 文章版权归本频道与文章作者所有.对于被频道转载文章的个人和网站,我们表示深深的谢意。

原始作者:佚名 录入时间:2007-6-29 10:25:11
信息来源:不详 投稿信箱:itqoo@126.com
教程录入:itqoo    责任编辑:itqoo 
  • 上一个教程:

  • 下一个教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    - 关于我们 - 合作伙伴 - 友情链接 - 广告刊登 - 投稿热线 - 在线留言版权声明联系方式 -
    IT公社版权所有 粤ICP备05127012号
    Copyrigh@2005-2006 itqoo.com.Inc All Rights Reserved  推荐分辨率 1024*768
    联系站长:E-Mail:itqoo@126.com     MSN:urchincc@hotmail.com    QQ:点击这里给我发消息
    特别感谢:亿太网络提供空间支持