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

来源:百度文库 编辑:中财网 时间:2024/05/11 04:24:19

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

 

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

AD:


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

    View demo

    login.html

    1. id="login">
    2. Log In

    3. id="inputs">
    4. id="username" type="text" placeholder="Username" autofocus required>
    5. id="password" type="password" placeholder="Password" required>
    6. id="actions">
    7. type="submit" id="submit" value="Log in">
    8. href="">Forgot your password? href="">Register

    所用到的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.hqchn.com