吉行天下, 力挽狂澜

----------吉豕皮, 力一女共筑----------
随笔 - 35, 文章 - 2, 评论 - 3, 引用 - 0
数据加载中……

Web页面小技巧

今天看到了几则web页面编程的文章,真是大开眼界,先贴到这里:
1,dropdownlist功能测试
<html>
<head>
<title></title>
</head>
<body>
<SELECT  onchange="javascript:var jmpURL=this.options[selectedIndex].value; if(jmpURL.substr(0,4)=='http') {location.href=jmpURL;} else {this.selectedIndex=0;}"> 
  
<OPTION selected>分类</OPTION> <OPTION 
  
value=http://www.baidu.com>百度</OPTION> <OPTION 
  value
=http://www.google.com>狗狗</OPTION><SELECT>
</body>
</html>

2,表单的妙用:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  
<title></title>
  
<style type="text/css">
  *{
  margin:0px;padding:0px;font-size:12px;
  }
    input{
      width:100px;height:20px;border:1px solid #ccc;
    }

  
</style>
</head>

<body>
<script language="javascript">
function tips(id,str){
var l=document.getElementById(id).offsetLeft+120;
var t=document.getElementById(id).offsetTop;
document.getElementById("tips").innerHTML="提示:"+str;
document.getElementById("tips").style.left=l+"px";
document.getElementById("tips").style.top=t+"px";
document.getElementById("tips").style.display="";
}
function outtips(){
    document.getElementById("tips").style.display='none';
}
</script>
<div id="tips" style="position:absolute;border:1px solid #ccc;padding:0px 3px;color:#f00;display:none;height:20px;line-height:20px;background:#fcfcfc"></div>
<br />
姓名:
<input type="text" id="username" onfocus="tips('username','姓名长度最多16个字符')" onblur="outtips()" />
<br />
密码:
<input type="password" id="password" onfocus="tips('password','密码长度必须在3-18位之间')" onblur="outtips()" />
</body>
</html>

3,样式表巧用
<br /><br /><br /><br /><br />
<class="tooltips" href="#tooltips">这就是Tooltips<span>如你所见,这些附加的说明文字在鼠标经过的时候显示。</span></a>
<style type="text/css">
/*Tooltips*/
.tooltips{
position:relative; /*这个是关键*/
z-index:2;
}
.tooltips:hover{
z-index:3;
background:none; /*没有这个在IE中不可用*/
}
.tooltips span{
display: none;
}
.tooltips:hover span{ /*span 标签仅在 :hover 状态时显示*/
display:block;
position:absolute;
top:21px;
left:9px;
width:15em;
border:1px solid black;
background-color:#ccFFFF;
padding: 3px;
color:black;
}
</style>

posted on 2006-09-28 13:42 吉豕皮 阅读(154) 评论(0)  编辑 收藏 引用 所属分类: web技术

只有注册用户登录后才能发表评论。