css教学实例(学生:Dream.Sky)

本文通过具体示例,详细讲解了如何使用HTML与CSS构建一个简单的搜索框,并结合JavaScript实现了基本的输入反馈功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天让学生实现一个搜索框的效果,死活做不出来,如图:

我就身教一回,代码如下:[ 点击下载]
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
    
< title > css教学(学生:Dream·Sky) </ title >
    
< style  type ="text/css" >
        .search
{ background : url(img/searchbg.jpg) ; width : 250px ; height : 37px ; }
        
/* 这里之所以用两个div是为了解决float:left的时候,margin-left在ie与ff下的不同解析 */
        .s_1
{ float : left ; width : 12px ; }
        .s_3
{ float : left ; width : 2px ; }
        
        .s_2
{ float : left ; width : 185px ; }
        .s_4
{ float : left ; width : 25px ; }
        .txt
{ width : 170px ; border : 0 ; margin-top : 8px ; color : #CCCCCC ; }
        .btn
{ margin-top : 5px ; }
    
</ style >
    
< script  type ="text/javascript" >
        
function  f(){
            alert(document.getElementById(
" Text1 " ).value);
        }
    
</ script >
</ head >
< body >
< div  class ="search" >
    
< div  class ="s_1" > &nbsp; </ div > <!-- 这里需要加空格,否则火狐下无效 -->
    
< div  class ="s_2" >
        
< input  id ="Text1"  type ="text"  class ="txt"  value ='搜索我们的产品..'  onclick ="this.value='';"   />
    
</ div >
    
< div  class ="s_3" > &nbsp; </ div >
    
< div  class ="s_4" >< input  type ="image"  src ="img/btnbg.jpg"  class ="btn"  onclick ="f();"   /></ div >
</ div >
</ body >
</ html >
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值