分享

使用HTML 5和CSS3制作登录页面完整步骤

 昵称8518470 2012-02-06

使用HTML 5和CSS3制作登录页面完整步骤

 

本文详细介绍使用HTML 5 和CSS3 制作一个登录页面的完整过程。

AD:

本文详细介绍使用HTML 5 和CSS3 制作一个登录页面的完整过程。

View demo

login.html

  1. <form id="login">
  2. <h1>Log In</h1>
  3. <fieldset id="inputs">
  4. <input id="username" type="text" placeholder="Username" autofocus required>
  5. <input id="password" type="password" placeholder="Password" required>
  6. </fieldset>
  7. <fieldset id="actions">
  8. <input type="submit" id="submit" value="Log in">
  9. <a href="">Forgot your password?</a><a href="">Register</a>
  10. </fieldset>
  11. </form>

所用到的HTML 5的特性:

◆ placeholder – 输入框的简短提示,当该输入框获得输入焦点时,该提示信息自动消失

◆ required – 指定该输入元素是否必须提供

◆ autofocus – 指定输入框是否在页面加载完毕自动获取输入焦点

◆ type=”password” – 指定密码输入(非HTML5专有)

CSS

在这里我们用到了 CSS3 的一些专有属性,包括:

Box-shadow 可以帮我们制作效果很好的边框阴影

  1. #login
  2. {
  3. box-shadow:
  4. 0 0 2px rgba(0, 0, 0, 0.2),
  5. 0 1px 1px rgba(0, 0, 0, .2),
  6. 0 3px 0 #fff,
  7. 0 4px 0 rgba(0, 0, 0, .2),
  8. 0 6px 0 #fff,
  9. 0 7px 0 rgba(0, 0, 0, .2);
  10. }

Stitch effect (缝效果)

  1. #login
  2. {
  3. position: absolute;
  4. z-index: 0;
  5. }
  6. #login:before
  7. {
  8. content: '';
  9. position: absolute;
  10. z-index: -1;
  11. border: 1px dashed #ccc;
  12. top: 5px;
  13. bottom: 5px;
  14. left: 5px;
  15. right: 5px;
  16. -moz-box-shadow: 0 0 0 1px #fff;
  17. -webkit-box-shadow: 0 0 0 1px #fff;
  18. box-shadow: 0 0 0 1px #fff;
  19. }

Subtle gradient lines (微妙的渐变线)

  1. h1
  2. {
  3. text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0px 2px 0 rgba(0, 0, 0, .5);
  4. text-transform: uppercase;
  5. text-align: center;
  6. color: #666;
  7. margin: 0 0 30px 0;
  8. letter-spacing: 4px;
  9. font: normal 26px/1 Verdana, Helvetica;
  10. position: relative;
  11. }
  12. h1:after, h1:before
  13. {
  14. background-color: #777;
  15. content: "";
  16. height: 1px;
  17. position: absolute;
  18. top: 15px;
  19. width: 120px;
  20. }
  21. h1:after
  22. {
  23. background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
  24. background-image: -webkit-linear-gradient(left, #777, #fff);
  25. background-image: -moz-linear-gradient(left, #777, #fff);
  26. background-image: -ms-linear-gradient(left, #777, #fff);
  27. background-image: -o-linear-gradient(left, #777, #fff);
  28. background-image: linear-gradient(left, #777, #fff);
  29. right: 0;
  30. }
  31. h1:before
  32. {
  33. background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
  34. background-image: -webkit-linear-gradient(right, #777, #fff);
  35. background-image: -moz-linear-gradient(right, #777, #fff);
  36. background-image: -ms-linear-gradient(right, #777, #fff);
  37. background-image: -o-linear-gradient(right, #777, #fff);
  38. background-image: linear-gradient(right, #777, #fff);
  39. left: 0;
  40. }

最终结果

View demo

结论

在一些老的浏览器上也表现不错,下图是在IE8下的效果:

原文:www.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多