标签


html深入学习(ajax,浏览器兼容性等)

2013年04月16日

左右侧导航, 顶部导航 : frame

html布局:
例子http://www.w3school.com.cn/html/html_layout.asp
div应用: display block/none

css中height:100%无效的解决方案
在前端设计中常常会遇到这样的问题:如何让容器高度100%填充整个body。大家都知道简单的给div定义一个height:100%是没有效果的,其实不然。下面我们来分析一下原因:CSS属性是有继承性的,而百分比都又是相对的,那么height:100%就是相当于容器父级而言的。所以并不是这个高度100%没有效果,只是没有达到我们预期的效果,我们理解上的错误。
理解了高度100%的意义,剩下的就简单了,给body一个100%高度即可。

html, body {height: 100%;}
#container {height: 100%;}

兼容性问题:

  1. 问题:ie7在onfocus()函数里显示不了this.type='password';?使得输入密码框的password不显示星号而显示字符 原因:IE下不支持修改input 的type属性

可以用两个input 一个是text 另一个是password之间的显示与隐藏来实现 这个功能

例子:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>hehe</title> 

</head> 
<style type="text/css"> 
</style> 
<body> 
<input name="" type="text" value="password" id="tx" style="width:150px;color:#777;"/> 
<input name="" type="password" style="display:none;width:150px;color:#777;" id="pwd" /> 
<script type="text/javascript"> 
var tx = document.getElementById_x_x_x_x_x_x_x_x_x_x_x("tx"), pwd = document.getElementById_x_x_x_x_x_x_x_x_x_x_x("pwd"); 
tx.onfocus = function () { 
    if (this.value == "password") 
    {
        this.style.display = "none"; 
        pwd.style.display = ""; 
        pwd.value = ""; 
        pwd.focus(); 
    }
} 
pwd.onblur = function () { 
    if (this.value == "") 
    {
        this.style.display = "none"; 
        tx.style.display = ""; 
        tx.value = "password"; 
    }
} 
</script> 
</body> 
</html> 
  1. 新问题: