CSS+DIV实现Yahoo搜索框的制作

2016-02-19 18:29 36 1 收藏

下面图老师小编跟大家分享CSS+DIV实现Yahoo搜索框的制作,一起来学习下过程究竟如何进行吧!喜欢就赶紧收藏起来哦~

【 tulaoshi.com - Web开发 】

  本文及代码由 renx 原创,版权所有,随便使用,哪位大大看得起在下,有用到的话,我很荣幸您能告诉我.

开始

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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

!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
titlesearch_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;i4;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
    lidiv id="m1" class="c_1"a href="###" onClick="aa(’1’)"分类第一/a/div/li
    lidiv id="m2" class="c_0"a href="###" onClick="aa(’2’)"分类第二/a/div/li
    lidiv 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
titlesearch_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 {borde

CSS教程是:CSS+DIV实现Yahoo搜索框的制作。r: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;i4;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
    lidiv id="m1" class="c_1"a href="###" onClick="aa(’1’)"分类第一/a/div/li
    lidiv id="m2" class="c_0"a href="###" onClick="aa(’2’)"分类第二/a/div/li
    lidiv 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"spanSearch the Web:/spaninput name="uid" id="uid_1" /span按钮/span/div/div
    div class="none" id="s2"div class="search_2"spanSearch the Web:/spaninput name="uid" id="uid_2" /span按钮/span/div/div
    div class="none" id="s3"div class="search_3"spanSearch the Web:/spaninput name="uid" id="uid_3" /span按钮/span/div/div
/div
/body
/html

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

!DOCTYPE html PUBLIC "-//W3C

CSS教程是:CSS+DIV实现Yahoo搜索框的制作。//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
titlesearch_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;i7;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();
      &n

CSS教程是:CSS+DIV实现Yahoo搜索框的制作。bsp; }
        else {
            document.getElementById("s"+i).className="none";
            document.getElementById("m"+i).className="c_0";
        }
    }
}
/script
/head
body
div class="s_c"ul
    lidiv id="m1" class="c_1"a href="###" onClick="aa(’1’)"b/b分类第一/a/div/li
    lidiv id="m2" class="c_0"a href="###" onClick="aa(’2’)"b/b分类第二/a/div/li
    lidiv id="m3" class="c_0"a href="###" onClick="aa(’3’)"b/b分类第三/a/div/li
    lidiv id="m4" class="c_0"a href="###" onClick="aa(’4’)"b/b分类第四/a/div/li
    lidiv id="m5" class="c_0"a href="###" onClick="aa(’5’)"b/b分类第五/a/div/li
    lidiv id="m6" class="c_0"a href="###" onClick="aa(’6’)"b/b分类第六/a/div/li
    /ul
/div
div class="s_b"
    div class="block" id="s1"div class="search_1"spanSearch the Web:/spaninput name="uid" id="uid_1" /span按钮/span/div/div
    div class="none" id="s2"div class="search_2"spanSearch the Images:/spaninput name="uid" id="uid_2" /span按钮/span/div/div
    div class="none" id="s3"div class="search_3"spanSearch the Images:/spaninput name="uid" id="uid_3" /span按钮/span/div/div
    div class="none" id="s4"div class="search_4"spanSearch the Audio/spaninput name="uid" id="uid_4" /span按钮/span/div/div
    div class="none" id="s5"div class="search_5"spanSearch the News/spaninput name="uid" id="uid_5" /span按钮/span/div/div
    div class="none" id="s6"div class="search_6"spanSearch the Shopping/spaninput name="uid" id="uid_6" /span按钮/span/div/div
/div
/body
/html

现在看来差不多可以了,就是效率有点低,下次再优化一下

来源:https://www.tulaoshi.com/n/20160219/1617891.html

延伸阅读
标签: Web开发
一般来说,指定高度的DIV垂直和水平居中比较方便,而不定高度的话就稍微麻烦了点,我尝试了一下,通过2个辅助的DIV实现了绝对居中,兼容IE和FF等标准浏览器。 CSS代码: #wrapper{height:100%;width:100%;overflow:hidden;position:relative} #wrapper[id]{display:table;} #mid{position: absolute;top:50%;left:50%} #mid[id]{dis...
标签: Web开发
以下是引用片段: style type="text/css" a{ color:#333333; text-decoration:none;} a:visited {color:#333333; text-decoration:none;} a:hover { color:#FF0000; text-decoration:underline;} a span { color:#333333;} /style a href="#"span111/span/a style type="text/css"a{ color:#333333; text-decor...
标签: Web开发
导言: 本文探讨的是圆角框的终极解决方案,其核心关键词是圆滑、完美、兼容、重用性、语义,这些技术都是收集目前网络上最流行的做法。纵观种种方法,各有其优势,请针对不同的环境分别使用。 圆角框,因为其样式比直角框漂亮,所以成为设计师心中偏爱的设计元素。现在的web标准下大量的网页、博客都采用圆角框设计,成为一道亮丽的风...
标签: Web开发
现在编写xhtml,我们强烈不推荐此种方法,应该是id,class综合应用。此文章只是讲述一种思维,并非建站过程中的方法! 用标准件的方式来组装网页DIV布局。我把class分为2种:布局class;风格class。 布局class是骨架,风格class是衣服。 举个例子:比如布局中的左栏。首先它的属性有:是左栏,宽度,背景颜色,字体颜色等。...
标签: Web开发
序言:在我的文章《超圆滑圆角框的半完美解决方案》中已经总结了七种不同的圆角框解决方案,基本上总结完了目前网络上比较流行的圆角框实现方案。而在我的另一篇文章《无图片山顶角》中又是一个另类的实现方法。 纯CSS实现圆角框是一件大家都说烂了的事件,我也写过两篇总结文章,为什么还会有这篇文章呢,事情是这样的。在我们的以前的项...

经验教程

490

收藏

100
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部