程序代码:
<html>
<head>
<!--<script type="text/javascript" src="http://code.-->
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function(){
$("input").focus(function(){
$("span, div").addClass("focus");
}).blur(function(){
$("span, div").removeClass("focus");
});
});
</script>
<style type="text/css">
*{padding: 0; margin: 0; font-size: 14px; font-family: "宋体";}
span{
position: absolute;
z-index: -1;
left: 8px;
color: gray;
}
span.focus{
top: -10px;
color: purple;
z-index: 2;
background: white;
}
input{
height: 16px;
line-height: 14px;
border: none;
position: absolute;
width: 200px;
left: 5px;
background: transparent;
}
.out-side{
margin: 20px;
height: 16px;
position: relative;
border: 1px gray solid;
float: left;
border-radius: 4px;
padding: 5px;
width: 200px;
}
.out-side.focus{
border-color: purple;
}
</style>
</head>
<body>
<div>
<div class="out-side">
<span>用户名/邮件</span>
<input type="text" name="usr" class="usr"/>
</div>
</div>
</body>
</html>