css怎么制作一个登录页面

html-css08

css怎么制作一个登录页面,第1张

CSS+HTML可以制作一个登录静态页面,做不了动态页面。

表单代码:

<form name="form" method="POST" action="">

<input type="text" value="用户名" />

<input type="password" value="密码" />

<input type="submit" name="button" value="登录" class="xiaoka_tj"/>

</form>

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

第二步,为文本框文字添加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>

效果图:

我使用的开发工具是JetBrains Webstorm,自行百度下,IDE很多,只是我很喜欢这个界面:

建立我们的项目:

1.新建一个空项目

2.建立html文件和 images文件夹以及css文件夹

3.提醒下 建立css文件的方法:

在index.html文件中 这样写: