div css中,在登陆界面“文本框”上有灰色的文字,点击中文文本框灰色的文字消失是什么原因?

html-css07

div css中,在登陆界面“文本框”上有灰色的文字,点击中文文本框灰色的文字消失是什么原因?,第1张

第一步,点击文本框,在属性栏中填写你需要的文字;见下图

第二步,为文本框文字添加css属性,点击文本框,可以在css面板中直接选择颜色或填写值;(可以在网页中直接定义css,也可以新建一个css文件)

显示效果

如果要实现鼠标点击灰色文字自动消失,需要使用js编程,可以在网上找js或jquery效果代码添加进页面内。

附上具体代码:

<!DOCTYPE html><html><head><style>.txt{    color:#ccc}.focus{    color:#333}</style><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><script>$(document).ready(function(){    var str="我是灰色文字"    $(".txt").val(str)         $(".txt").focus(function(){        var v=this.value        if(v == str){            $(this).val("").addClass("focus")        }    }).blur(function(){        var v=this.value        if(v == ""){            $(this).val(str).removeClass("focus")                     }    })})</script></head><body><input class="txt" type="text" value="我是灰色文字"/></body></html>

用div+css制作一个登录页面,首先需要做的就是将这个登录界面的布局给构想好,然后在使用div去布局出来,一般都要结合表单,因为是需要和数据库结合的,至于的具体的界面,看下代码:

<html>

<head>

<meta charset="UTF-8">

<title>淘宝登录</title>

<link rel="stylesheet" type="text/css" href="../static/css/index.css" />

<script type="text/javascript">

<{if $message !=''}>

alert("<{$message}>")

<{/if}>

</script>

</head>

<body>

<div id="logo">

<div class="logotop">

<div class="yanz">

<h2>登录</h2>

<form action="logo.php" method="post">

<span style="display:blockheight:27pxwidth:27pxbackground-image:url(../static/images/logozh.jpg)float:left"></span>

<input type="text" name="uname" style="height:26px"/><br/>

<span style="display:blockheight:27pxwidth:27pxbackground-image:url(../static/images/logomm.jpg)float:left"></span>

<input type="password" name="pwd" style="height:26px"/>

<p><a href="">忘记登录密码?</a></p>

<input type="submit" value="" style="width:254pxheight:37pxbackground-image:url(../static/images/logodl.jpg)cursor: pointer"/>

</form>

</div>

</div>

</div>

</body>

</html>

这个代码有些图片的地址,需要根据要求去改,这些是我自己写的,然后就是传输的文件,action那,接受的文件也是需要定义的。

<div id="zuo">

<!--<input type="button" value="往左" class="y">-->

<h1>登 陆</h1>

<form method="post" action="ok.html">

<p class="form_zh"><input type="text" placeholder="请输入账号" class="form_zh_y" autofocus = "autofocus" required = "required"></p>

<p class="form_mm"><input type="password" placeholder="请输入密码" class="form_zh_e" required = "required"></p>

<input type="submit" value="登 录" class="form_dl">

</form>

<p class="qtfsdl"><span><img src="images/weixin.jpg" />微信登陆</span><span><img src="images/QQ.jpg" />QQ登陆</span></p>

<p class="qtfsdr"><img src="images/frm_xia.jpg"/></p>

<p class="y">注 册</p>

<!--<div class="y1" style="position: absolutetop:250pxleft: -159pxwidth: 260pxheight: 47pxbackground: redopacity: 0.5"></div>-->

</div>

#zuo{

width: 500px

height: 540px

background: white

position: absolute

top: calc(50% - 250px)

left:calc(50% - 250px)

color: #292929

}

#zuo h1,#you h1{margin-top:30pxfont-weight: boldtext-align: centermargin-bottom: 30px}