表单宽高不固定情况下,表单外面加一个父标签fa 表单加一个类centered
<body><div class="fa">
<form name="search" method="post" action="#" class="centered">
<input value="请输入关键词" type="text" name="q" />
<input type="submit" value="搜索"/>
</form>
</div>
</body> 清除页面默认样式后(margin padding)
<style type="text/css">
html,body{width: 100%height: 100%}
.fa {text-align: centerheight: 100%}
.fa:before {content: ''display: inline-blockheight: 100%vertical-align: middle}
.centered {display: inline-blockvertical-align: middlebackground: redwidth: auto}
</style>
<html><head>
<title>fa</title>
</head>
<body>
<script type="text/javascript">
function rec(form) {
var a = form.aa.value
if (a > 50 && a < 60) {
alert("继续")
} else if (a >= 60 && a < 80) {
alert("很一般啊")
} else if (a > 80) {
alert("很好")
} else {
alert("垃圾")
}
}
</script>
<form>
<input type="text" name="aa" />
<input type="button" name="button" value="计算" onclick="rec(this.form)" />
</form>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)