用HTML前端技术做一个登入了界面+一些小技巧
效果图先上:
所以进入整体:
该登入界面只涉及HTML和CSS,暂时不涉及javascript;
首先就是壁纸,要想壁纸不重复,而且大小平铺我们可以创建一个div,使div的背景图为整个页面的壁纸:
- <body>
- <div id="wapper"></div>
- </body>
- #wallpaper
- {
- height:100%;
- width:100%;
- position:absolute;
- top:0px;
- left:0px;
- z-index:0;
- background:url("../pic/login_bg.jpg");
- background-size:cover;
- min-width:1000px;
- min-height:550px;
- }
编写这样的代码能够使我们的背景图片根据浏览器的大小来自动改变图片大小;
关于登入界面的话就主要分为两个部分:
Header和Content;
header的制作比较简单就直接上代码了吧:
- <div id="board_head">
- <img src="./pic/user.png" height="40px" width="40px">
- </div>
- #login_board #board_head
- {
- width:400px;
- height:40px;
- text-align:left;
- background:rgba(255,255,255,0.2);
- border-top-left-radius:14px;
- border-top-right-radius:14px;
- }
注意: text-align:left;的作用就是要让图片靠向左边;
然后就是界面主体:
- <div id="board_body">
- <div id="body_img">
- <img style="border-radius:50px;" src="./pic/myicon.gif" height="100px" width="100px">
- </div>
- <div id="input_board">
- <div id="input_icon"></div>
- <input id="password_input" type="password">
- <button id="check_button" onclick="check();"> </button>
- </div>
- </div>
接下来我们逐一来分析解释:
- #board_body #body_img
- {
- width:100px;
- height:100px;
- margin:30px auto;
- box-shadow: 0px 0px 15px -3px #fff;
- border-radius: 50px;
- }
这是用户头像的框架:主要是margin:auto;表示居中;圆角特效:border-radius:50px;圆角像素越大那么就可以是元素变成一个圆;阴影特效:box-shadow:0px 0px 15px -3px #fff;参数有点多.
接下就是输入框和点击按钮,输入框的左侧放置了一张图片,这张图片嵌套在一个div之中,为了保证该div与输入框能够完美的契合,所以我们需要把输入框input的一些默认的样式给清楚:
- border: none;
- padding:0px;
当然如果你需要在输入的时候边框是会有颜色的话可是使用onblur事件;
- #board_body #input_board
- {
- text-align:center;
- margin: auto;
- width:330px;
- height:30px;
- padding-left: 30px;
- }
- #input_board #input_icon
- {
- height:100%;
- width:20px;
- background-color:rgba(255,255,255,0.2);
- background-image:url("../pic/input.png");
- background-size:90%;
- background-repeat:no-repeat;
- background-position:center;
- border-top-left-radius: 5px;
- border-bottom-left-radius: 5px;
- float: left;
- }
- #input_board #password_input
- {
- height:100%;
- width:250px;
- padding:0px;
- background:rgba(255,255,255,0.2);
- border: none;
- font-size: 18px;
- border-top-right-radius: 5px;
- border-bottom-right-radius: 5px;
- float: left;
- }
- #input_board #check_button
- {
- height:30px;
- width:30px;
- background:url("../pic/enter.png");
- background-color:rgba(255,255,255,0.2);
- background-size:cover;
- border: none;
- border-radius: 30px;
- float: left;
- cursor:pointer;
- margin-left:20px;
- }
- #input_board #check_button:hover{
- background-color:rgba(255,255,255,0.7);
- }
在check_button中有一个hover使鼠标在元素上方显示不同的样式;
总体就是这样.