【宿舍管理系统】注册登录页面的实现(前端)

news2025/2/8 14:59:32

目录

一.创建一个jsp文件,命名为login.jsp

代码:

1.

2.

3.

 4.

 5.

6.

​编辑

二. 创建一个css文件,并命名为style.css

1.

​编辑效果如下:

​编辑 代码解析:

2.

效果如下:

代码解析:

 3.

效果如下:

 代码解析:

4.

效果如下:

 代码解析:

5.

效果如下:

​编辑

代码解析:

6.

效果如下:

​编辑

代码解析:

 7.

效果如下:

 代码解析:

8.

效果如下:

代码解析:

9.

10.

效果如下:

11.

 效果如下:

三.代码


效果图

一.创建一个jsp文件,命名为login.jsp

制作如下样本

代码:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<body>
<form action="${pageContext.request.contextPath}/login" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>
                <div class="login-center-input">
                    <input type="text" id="username" name="username" placeholder="请输入您的用户名" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                    <div class="login-center-input-text">用户名</div>
                </div>
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/password.png"/></div>
                <div class="login-center-input">
                    <input type="password" id="password" name="password" placeholder="请输入您的密码" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
                    <div class="login-center-input-text">密码</div>
                </div>
            </div>
            <div class="login-button" onclick="check()">
                登录
            </div>
            <span style="text-align: center;color: red;"><br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;${msg}</span>
        </div>
        <div class="sk-rotating-plane"></div>
    </div>
</form>

</body>

此段代码只完成前端页面展示的任务

1.

<form action="${pageContext.request.contextPath}/login" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            
           
           
            
        </div>
        
    </div>

效果如下:

2.

<form action="${pageContext.request.contextPath}/login" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

                </div>


        </div>

    </div>
效果如下:

<div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

此行代码调用了images文件中的name.png图像

3.

<div id="particles-js">
    <div class="login">
        <div class="login-top">
            后台登录
        </div>
        <div class="login-center clearfix">
            <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

            <div class="login-center-input">
                <input type="text" id="username" name="username" placeholder="请输入您的用户名" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                <div class="login-center-input-text">用户名</div>
            </div>
      
        </div>
       
       
    </div>
   
</div>


            <div class="login-center-input">
                <input type="text" id="username" name="username" placeholder="请输入您的用户名" οnfοcus="this.placeholder=''" οnblur="this.placeholder='请输入您的用户名'"/>
                <div class="login-center-input-text">用户名</div>
            </div>

type="text"表示该输入框是一个文本框。

id="username":为该输入框指定了一个唯一的标识符,可以通过该标识符来访问和操作该输入框。

name="username":指定了该输入框的名称,可以在表单提交时将输入框的值与名称一起提交到服务器。

placeholder="请输入您的用户名":该属性为输入框提供了一个提示文本,当用户未输入任何内容时,该文本将显示在输入框中。在这种情况下,它将显示"请输入您的用户名"。

οnfοcus="this.placeholder=''":当用户将焦点放在输入框内时,该代码将清空提示文本,以便用户可以直接输入内容。

οnblur="this.placeholder='请输入您的用户名'":当用户将焦点移出输入框时,如果该输入框中没有输入任何内容,则该代码将重新显示"请输入您的用户名"提示文本。

      效果如下:

 

 4.

<body>
<form action="${pageContext.request.contextPath}/login" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

                <div class="login-center-input">
                    <input type="text" id="username" name="username" placeholder="请输入您的用户名"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                    <div class="login-center-input-text">用户名</div>
                </div>
            </div>

            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/password.png"/></div>
                <div class="login-center-input">
                    <input type="password" id="password" name="password" placeholder="请输入您的密码"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
                    <div class="login-center-input-text">密码</div>
                </div>
            </div>





        </div>

    </div>
</form>

<div class="login-center clearfix">
    <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/password.png"/></div>
    <div class="login-center-input">
        <input type="password" id="password" name="password" placeholder="请输入您的密码"
               οnfοcus="this.placeholder=''" οnblur="this.placeholder='请输入您的密码'"/>
        <div class="login-center-input-text">密码</div>
    </div>
</div>

效果如下:

 

 5.

<form action="${pageContext.request.contextPath}/login" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

                <div class="login-center-input">
                    <input type="text" id="username" name="username" placeholder="请输入您的用户名"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                    <div class="login-center-input-text">用户名</div>
                </div>
            </div>

            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/password.png"/></div>
                <div class="login-center-input">
                    <input type="password" id="password" name="password" placeholder="请输入您的密码"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
                    <div class="login-center-input-text">密码</div>
                </div>
            </div>

            <div class="login-button" onclick="check()">
                登录
            </div>





        </div>

    </div>
</form>

<div class="login-button" οnclick="check()">
                登录
            </div>

效果如下:

 

6.

<span style="text-align: center;color: red;"><br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;${msg}</span>

这段代码是在HTML或其他网页标记语言中使用的,它会在页面上显示一个红色文本(文字颜色为红色)的信息,其中${msg}是一个占位符,表示实际显示的消息将由程序或代码动态生成并填充到此处。通过使用居中对齐样式(text-align: center),文本将被放置在页面的中心位置。如果您使用的是某个Web框架或库,这段代码可能已经被预先定义在其中,并且可以非常方便地在您的项目中使用。

二. 创建一个css文件,并命名为style.css

要使用style.css里的样式,必须在login里添加

<link rel="stylesheet" media="screen" href="${pageContext.request.contextPath}/css1/style.css">

1.

html,body{
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}

此段代码是关于背景图像的样式

对应如下图所示

效果如下:

 代码解析:

`width: 100%;`: 设置该元素的宽度为 100%。
- `height: 100%;`: 设置该元素的高度为 100%。
- `position: relative;`: 设置该元素在文档流中的定位为相对定位。
- `background-image: url(../images/bg.jpg);`: 设置该元素的背景图片为 `../images/bg.jpg`。
- `background-position: 50% 50%;`: 设置背景图片在元素中水平和垂直方向上的位置为 50%。
- `background-size: cover;`: 设置背景图片按比例缩放以完全覆盖整个元素。
- `background-repeat: no-repeat;`: 禁止背景图片在元素中重复显示。
- `margin-left: auto;`: 设置该元素的左侧外边距为自动。
- `margin-right: auto;`: 设置该元素的右侧外边距为自动。

2.

html,body{
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}


.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}

.login{z-index: 2;
       position:absolute;
       width: 350px;
       border-radius: 5px;
       height: 500px;
       background: white;
       box-shadow: 0px 0px 5px #333333;
       top: 50%;
       left: 50%;
       margin-top: -250px;
       margin-left: -175px;
       transition: all 1s;
       -moz-transition: all 1s; 
       transition: all 1s; 
       -o-transition: all 1s;   }

此行代码对应

效果如下:

代码解析:

- z-index:  2;    控制元素的层级,数值越大越靠前显示。
- position: absolute;     元素的定位方式,这里是绝对定位,相对于父级元素进行定位。
- width:350px;   宽设置为350px

- height: 500px;    高设置为500px
- border-radius:  5px;   元素的圆角度数。(效果图中白色盒子四个圆角的度数)
- background: white;         元素的背景颜色。
- box-shadow:  0px 0px 5px #333333;                 元素的阴影样式。

 -top: 50%;
- left: 50%;
- top和left:    元素相对于父级元素的顶部和左侧位置。

- margin-top: -250px;
- margin-left: -175px;
- margin-top和margin-left: 元素相对于自身所在位置的上方和左侧的距离,一般用于居中元素。

transition: all 1s;
  -moz-transition: all 1s;
  transition: all 1s;
  -o-transition: all 1s;
- transition和-moz-transition和-o-transition: 控制元素变化过程的动画时长和效果。

 3.

html,body{
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}


.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}

.login-top{font-size: 24px;
           margin-top: 100px;
           padding-left: 40px;
           box-sizing: border-box;
           color: #333333;
           margin-bottom: 50px;}
此行代码对应

此行代码主要作用于后台登录这四个字上

效果如下:

 代码解析:

  font-size: 24px; 设置字体大小为24像素。
- margin-top: 100px; 设置该元素的顶部边缘距离它的容器顶部边缘100像素的距离。
- padding-left: 40px; 设置该元素左侧内边距为40像素。
- box-sizing: border-box; 指定元素的盒模型为border-box,也就是指定元素的宽度和高度包括边框(border)和内边距(padding)。
- color: #333333; 设置文本颜色为#333333,即十六进制颜色码之一。
- margin-bottom: 50px; 设置该元素的底部边缘距离它的容器底部边缘50像素的距离。

4.

html,body{
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}


.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center{width: 100%;
              box-sizing: border-box;
              padding: 0 40px;
              margin-bottom: 30px;}

此段代码的作用起到居中的作用

此段代码如下:

效果如下:

 代码解析:

.login-center { width: 100%; // 设置该元素的宽度为100%

box-sizing: border-box; // 定义元素的盒模型为border-box,即元素的border和padding值不会增加元素宽度和高度

padding: 0 40px; // 设置元素内边距为0,左右间距为40px

margin-bottom: 30px; // 设置元素下方的外边距为30px }

5.

html,body{
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}


.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-img{width: 20px;
                 height: 20px;
                 float: left;
                 margin-top: 5px;}
.login-center-img>img{width: 100%;}

此行代码对应:

效果如下:

代码解析:

.login-center-img表示该元素的类名;

width: 20px; 表示该元素的宽度为20像素;

height: 20px; 表示该元素的高度为20像素;

float: left; 表示该元素浮动到左侧;

margin-top: 5px; 表示该元素顶部与其上面的元素之间有5像素的间隔。

.login-center-img>img{width: 100%;}

作用是将< img >标签的宽度设置为100%。也就是说,< img >标签将会填满其父元素的宽度,而不是保持其原有的宽度。这通常用于确保图像在不同的设备上保持适当的比例和大小以便显示。

6.

html,body{ 
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}



.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input{
float: left;
width: 230px;
margin-left: 15px;
height: 30px;
position: relative;}
login-center-input input{
z-index: 2;
transition: all 0.5s;
padding-left: 10px;
color: #333333;
width: 100%;
height: 30px;
border: 0;
border-bottom: 1px solid #cccccc;
border-top: 1px solid #ffffff;
border-left: 1px solid #ffffff;
border-right: 1px solid #ffffff;
box-sizing: border-box;
outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}

此段代码对应

效果如下:

代码解析:

float: left意味着该元素应该向左浮动,允许其他元素在其右侧排列。

width: 230px指定该元素的宽度为230个像素。

margin-left: 15px将该元素的左侧外边距设置为15个像素,从而在其左侧留出一些空间。

height: 30px指定该元素的高度为30个像素。

position: relative将该元素的定位类型设置为相对定位,这意味着它将相对于其正常位置进行定位,而不是相对于上级元素进行定位。

z-index: 2 - 它决定该元素的堆叠顺序(在其它重叠的元素上下文中),具有更高的 z-index 值将位于具有更低值的元素的上方。

transition: all 0.5s - 它以动画效果过渡了所有样式属性的变化,使得它们更加平滑。

padding-left: 10px - 它设置了该元素的左侧填充。

color: #333333 - 它设置了该元素的文字颜色。

width: 100% - 它设置了该元素的宽度为父元素的宽度。

height: 30px - 它设置了该元素的高度。

border: 0 - 它移除了该元素的默认边框。

border-bottom: 1px solid #cccccc - 它设置了该元素的底部边框为 1 像素宽,颜色为 #cccccc。

border-top: 1px solid #ffffff - 它设置了该元素的上部边框为 1 像素宽,颜色为 #ffffff。

border-left: 1px solid #ffffff - 它设置了该元素的左侧边框为 1 像素宽,颜色为 #ffffff。

border-right: 1px solid #ffffff - 它设置了该元素的右侧边框为 1 像素宽,颜色为 #ffffff。

box-sizing: border-box - 它设置元素框大小包括边框和内边距,但不包括外边距。这意味着该元素的宽度和高度将是指定的内容大小加上边框和填充大小。

outline: none - 它移除了该元素在获得焦点时的默认描边效果。

position: relative - 它设置了该元素的位置方式为相对位置。

.login-center-input input:focus{border: 1px solid dodgerblue;}

其作用是在用户点击一个输入框时,给这个输入框加上一个蓝色的边框。

 7.

html,body{ 
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}



.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input-text{background: white;
                        padding: 0 5px;
                        position: absolute;
                        z-index: 0;
                        opacity: 0;
                        height: 20px;
                        top: 50%;
                        margin-top: -10px;
                        font-size: 14px;
                       left: 5px;
                       color: dodgerblue;
                      line-height: 20px;
                      transition: all 0.5s;
                    -moz-transition: all 0.5s; 
                  -webkit-transition: all 0.5s; 
                   -o-transition: all 0.5s;}

此段代码作用如下

效果如下:

 代码解析:

background:背景颜色为白色。

padding:输入框左右两侧内边距为5像素,上下内边距默认。

position:输入框的定位方式为绝对定位。

z-index:图层的层级为0,即在默认层级显示。

opacity:输入框的不透明度为0,即不可见。

height:输入框的高度为20像素。

top:输入框相对父元素(登录中心)垂直居中对齐。

margin-top:使输入框在垂直方向上以自身高度的一半偏移,来实现完全垂直居中。

font-size:输入框内文字的字号为14像素。

left:输入框距离左边的间距为5像素。

color:输入框内文字的颜色为dodgerblue。

line-height:输入框内文字的行高为20像素,与输入框高度相同。

transition:所有的属性变化都会有0.5秒的过渡动画效果。

-moz-transition:指定火狐浏览器里所有的属性变化都会有0.5秒的过渡动画效果。

-webkit-transition:指定谷歌浏览器里所有的属性变化都会有0.5秒的过渡动画效果。

-o-transition:指定欧朋浏览器里所有的属性变化都会有0.5秒的过渡动画效果。

8.

html,body{ 
	width:100%;
	height:100%;
}

#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}



.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
.login-center-input input:focus~.login-center-input-text{top: 0;
                                                       z-index: 3;
                                                       opacity: 1;
                                                      margin-top: -15px;}

效果如下:

代码解析:

.login-center-input input:focus~.login-center-input-text{top: 0;
                                                       z-index: 3;
                                                       opacity: 1;
                                                      margin-top: -15px;}

当一个输入表单获得焦点时(例如,用户点击或按Tab键进入该表单),对于其相邻的类名为.login-center-input-text的元素,做以下操作:

把该元素的位置定位在输入框顶部(top: 0)。

在其他元素上方使其显示(z-index: 3)。

将其不透明度设置为1(opacity: 1),以便用户可以看到其内容。

将其上方的间距设置为-15像素(margin-top: -15px),以抵消文本移动而产生的留白。

9.

html,body{ 
	width:100%;
	height:100%;
}





#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}


.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
.login-button{cursor: pointer;width: 250px;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;}

.login-button{cursor: pointer;width: 250px;
              text-align: center;
              height: 40px;
              line-height: 40px;
              background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;}

用于设置登录按钮的样式。其中,设置了按钮的宽度、高度、行高、背景颜色、圆角等属性,并将按钮居中显示在页面上方。使用了"cursor: pointer"属性,使得鼠标悬停在上按钮时会变成手型,增强用户体验。同时,设置了文字按钮的颜色为白色。

10.

html,body{ 
	width:100%;
	height:100%;
}


.js-count-particles{
  font-size: 1.1em;
}

#stats,
.count-particles{
  -webkit-user-select: none;
  margin-top: 5px;
  margin-left: 5px;
}

#stats{
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.count-particles{
  border-radius: 0 0 3px 3px;
}


#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}

body{margin:0;padding:0;}

.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
.login-button{cursor: pointer;width: 250px;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;}

body{margin:0;padding:0;}

body中元素的边距和内边距为0。这样可以让整个页面的内容紧贴着浏览器窗口显示,不会有额外的空白区域

效果如下:

 背景图像完全覆盖了网页页面

11.

html,body{ 
	width:100%;
	height:100%;
}


.js-count-particles{
  font-size: 1.1em;
}

#stats,
.count-particles{
  -webkit-user-select: none;
  margin-top: 5px;
  margin-left: 5px;
}

#stats{
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.count-particles{
  border-radius: 0 0 3px 3px;
}


#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}

body{margin:0;padding:0;}
.clearfix:after{visibility:hidden;display: block;font-size:0;content:" ";clear:both;height:0;}

.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
.login.active{-webkit-animation: login-small 0.8s ; animation: login-small 0.8s ;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards}
.login-button{cursor: pointer;width: 250px;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;}

.clearfix:after{visibility:hidden;
                 display: block;
                 font-size:0;
                  content:" ";
                  clear:both;
                  height:0;}

用于一个创建清除浮动的类。通过在元素上添加这个类,可以清除元素的中浮动,防止对后续元素造成影响。其中,使用了伪元素":after"来插入一个空格,达到清除浮动的效果。

 效果如下:

三.代码

相关文件,图像下载:

https://download.csdn.net/download/m0_67930426/87902949?spm=1001.2014.3001.5503

login.jsp

<%--
  Created by IntelliJ IDEA.
  User: 23502
  Date: 2023/6/3
  Time: 18:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    
    <link rel="stylesheet" media="screen" href="${pageContext.request.contextPath}/css1/style.css">




    <title>Title</title>
</head>

<body>
<form action="${pageContext.request.contextPath}/2" name="myform" method="post">
    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                后台登录
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/name.png"/></div>

                <div class="login-center-input">
                    <input type="text" id="username" name="username" placeholder="请输入您的用户名"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                    <div class="login-center-input-text">用户名</div>
                </div>
            </div>

            <div class="login-center clearfix">
                <div class="login-center-img"><img src="${pageContext.request.contextPath}/images/password.png"/></div>
                <div class="login-center-input">
                    <input type="password" id="password" name="password" placeholder="请输入您的密码"
                           onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
                    <div class="login-center-input-text">密码</div>
                </div>
            </div>

            <div class="login-button" onclick="check()">
                登录
            </div>

            <span style="text-align: center;color: red;"><br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;${msg}</span>

        </div>
        <div class="sk-rotating-plane"></div>
    </div>
</form>

</body>
</html>

style.css

html,body{ 
	width:100%;
	height:100%;
}


.js-count-particles{
  font-size: 1.1em;
}

#stats,
.count-particles{
  -webkit-user-select: none;
  margin-top: 5px;
  margin-left: 5px;
}

#stats{
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.count-particles{
  border-radius: 0 0 3px 3px;
}


#particles-js{
	width: 100%;
	height: 100%;
	position: relative;
	background-image: url(../images/bg.jpg);
	background-position: 50% 50%;
	background-size: cover;
	background-repeat: no-repeat;
	margin-left: auto;
	margin-right: auto;
}

body{margin:0;padding:0;}
.clearfix:after{visibility:hidden;display: block;font-size:0;content:" ";clear:both;height:0;}

.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;background: white;box-shadow: 0px 0px 5px #333333;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s;	/* Firefox 4 */-webkit-transition: all 1s;	/* Safari 和 Chrome */-o-transition: all 1s;	/* Opera */}
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;}
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
.login-center-img>img{width: 100%;}
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
.login-center-input input:focus{border: 1px solid dodgerblue;}
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s;	/* Firefox 4 */-webkit-transition: all 0.5s;	/* Safari 和 Chrome */-o-transition: all 0.5s;	/* Opera */}
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
.login.active{-webkit-animation: login-small 0.8s ; animation: login-small 0.8s ;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards}
.login-button{cursor: pointer;width: 250px;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/646307.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何做好《关键信息基础设施安全保护要求》提到的收敛暴露面?

5月1日&#xff0c;《信息安全技术 关键信息基础设施安全保护要求》&#xff08;GB/T 39204-2022&#xff09;国家标准正式实施。该标准作为关键信息基础设施安全保护标准体系的构建基础&#xff0c;提出了关键信息基础设施安全保护的三项基本原则&#xff0c;为运营者开展关键…

华为OD机试真题 JavaScript 实现【最左侧冗余覆盖子串】【2023Q2 100分】

一、题目描述 给定两个字符串 s1 和 s2 和正整数k&#xff0c;其中 s1 长度为 n1&#xff0c;s2 长度为 n2&#xff0c; 在s2中选一个子串&#xff0c;满足: 该子串长度为n1k&#xff1b;该子串中包含s1中全部字母&#xff1b;该子串每个字母出现次数不小于s1中对应的字母&am…

2023年,现在学Python还吃香吗?计算机专业怎么样?

自从ChatGPT诞生以来&#xff0c;各大科技公司纷纷推出了自己的AI产品&#xff0c;在这个赛道上卷生卷死&#xff0c;纷纷布局。 从Google的Bard AI、OpenAI出走团队的Claude&#xff0c;到中国的众多公司&#xff0c;如百度的文心一言。 总的来说&#xff0c;AI的应用领域日…

Java培训周期一般多长?Java培训班过来人告诉你!

市场上比较靠谱的java培训机构的培训时间一般都是5-6个月&#xff0c;好程序员是4个月&#xff0c;个别培训机构可能因为班型不同而有所区别。学的时间太短学到的知识可能会有遗漏&#xff0c;造成基础不扎实;学习时间太长也会过于拖沓&#xff0c;还降低了整个培训的性价比。 …

qt creator使用问题

qt creator 多版本安装需要卸载之前的版本&#xff0c;安装目录默认在Qt目录下&#xff08;qt的sdk也在qt目录下&#xff09; 编译过程中遇到一些很奇怪问题&#xff0c;建议优先重新编译。 issue qtcreator inappropriate for the inferior 构建套件&#xff0c;前面的感…

YOLO-V5分类实战系列 —— 快速训练自己的数据集

YOLO-V5 训练自己的分类模型 1、获取官方源码2、测试官方源码2.1、公开数据集测试源码 3、源码模块解析3.1、数据读取 4、快速开始训练自己的数据4.1、准备自己的数据4.2、配置训练参数 1、获取官方源码 官方代码&#xff1a;https://github.com/ultralytics/yolov5 更新版本&a…

【Matter】Matter学习笔记1

文章目录 前言Matter协议架构1.Matter Over IPV62.Matter协议架构3.Matter标准协议架构 Matter网络拓扑结构Mesh组网1.单一网络拓扑2.星形网络拓扑 设备数据模型&#xff08;Date Model&#xff09;1.设备和端点&#xff08;Node、Endpoint&#xff09;2.节点角色&#xff08;N…

58、基于51单片机GPS定位自动报站时间显示语音播报公交车系统设计(程序+原理图+PCB源文件+参考论文+开题报告+任务书+元器件清单等)

摘 要 1831年&#xff0c;英国的沃尔特汗考为他的国家制造出了世界上第一辆装载发动机的公共汽车&#xff0c;至今&#xff0c;公交车已经经历过近200年的发展过程。从刚开始“闷罐头”样式到如今配套空调系统&#xff1b;从专人售票至无人售票&#xff1b;从人工报站至半自动…

咖啡店小程序开发 让烟火小店更有生机

随着人们生活水平的提高和生活压力的增大&#xff0c;很多人都靠喝咖啡来缓解疲劳和压力&#xff0c;也为我们的生活增添了一丝情趣&#xff0c;但高峰时期排队购买一杯咖啡很浪费时间&#xff0c;很多赶时间的上班族不得不放弃。随着互联网技术深入到各行各业&#xff0c;传统…

电商人看过来,这个 AI 工具可以一键生成商品背景图

在2023年&#xff0c;如果你还不会玩AI&#xff0c;那你就out了。如果AI只是作为娱乐的话&#xff0c;学起来还是挺费劲的&#xff0c;但是如何将AI嵌入到我们的工作流程中&#xff0c;从而提升工作效率&#xff0c;这很重要。 于是&#xff0c;经过小编一个下午的疯狂测试&am…

华为OD机试真题 JavaScript 实现【通信误码】【2022Q4 100分】,附详细解题思路

一、题目描述 信号传播过程中会出现一些误码&#xff0c;不同的数字表示不同的误码ID&#xff0c;取值范围为1~65535&#xff0c;用一个数组记录误码出现的情况。 每个误码出现的次数代表误码频度&#xff0c;请找出记录中包含频度最高误码的最小子数组长度。 二、输入描述 …

【色度学】颜色的显色系统

我的理解&#xff1a; HSV模型应该对应的是下面的&#xff1a;色相、视明度、饱和度的定义。 1. 色彩的心里属性 1.1 色相Hue 色相是指颜色的基本相貌&#xff0c;它是颜色彼此区别的最主要和最基本的特征&#xff0c;它表示颜色质的区别&#xff0c;也叫色调。 从光的物理刺…

大厂精简人员,技术人员如何跳出“舒适圈”

你还记得自己为求职焦虑是什么时候吗&#xff1f; 是刚毕业找工作&#xff0c;还是第一次跳槽&#xff0c;还是在毫无准备的情况下被优化掉&#xff1f; 疫情下&#xff0c;裁员消息成为这个年底让所有互联网从业人员最为关注的新闻。企业选择剥离主线业务之外的枝枝蔓蔓&…

Mediapipe实时3D目标检测和跟踪(自动驾驶实现)

&#x1f680; 导语 3D目标检测是根据物体的形状、位置和方向来识别和定位物体的任务。在2D目标检测中&#xff0c;被检测到的物体仅表示为矩形边界框。3D目标检测任务通过预测物体周围的包围框&#xff0c;可以获取物体的三维位置信息。 3D目标检测在各行各业都有广泛的应用。…

(2023年最新版)史上最全Python/Java自动化测试学习路线图!没有之一!

废话少说&#xff0c;直接上干货&#xff01; 保证是你2023年看到最全最详细的自动化测试进阶学习路线全栈图&#xff01;&#xff01;赶紧保存&#xff01; 由于全图图片太大上传不了&#xff0c;这里就不展示了。需要的小伙伴们可以文末小卡片联系我 下面展示部分截图&#…

express的使用(四) nodejs转发表单到后台

原文链接 搬砖的林小白-express的使用(四) 个人博客地址&#xff0c;求关注&#xff0c;也希望大家在里面批评我的不足之处 看前提示 本篇所讲述的内容是node端转发前端发送过来的表单到第三方中&#xff0c;应用的场景有很多&#xff0c;如我们经常做的将文件存储到七牛云或…

Cesium教程(十八):可视域分析

Cesium教程(十八):可视域分析 三维可视域分析是计算从某点出发的视线在一定视角范围内能通视的区域。是一种常规的三维空间分析手段。Cesium没有封装完整的可视域分析方法,这里提供简单的可视域分析的简化实现方法。 效果预览 其中需要另外引入四个js文件。下载地址在文章最…

5年测试经验怎么着我也能要个20K吧?没想到被阿里P8问傻了····

都说金三银四是跳槽涨薪季&#xff0c;我也是着急忙慌的准备简历——5年软件测试经验&#xff0c;可独立测试大型产品项目&#xff0c;熟悉项目测试流程…薪资要求&#xff1f;5年测试经验起码能要个20K吧&#xff1f; 我加班肝了一页半简历&#xff0c;投出去一周&#xff0c…

软件测试如何提高自己的工作汇报能力?

汇报自己的工作是一件非常重要的事&#xff0c;但往往被一些人忽视掉。 我有个朋友&#xff0c;他带的组里有一个小伙子&#xff0c;技术能力不错&#xff0c;代码也写得干净漂亮&#xff0c;但是不喜欢汇报自己的工作成果&#xff0c;他的想法是&#xff1a;我做完的东西&…

【Spring源码解读四】IoC容器之AnnotationConfigApplication的refresh()刷新方法其三

finishBeanFactoryInitialization() freezeConfiguration() preInstantiateSingletons() getBean() 这一篇博文主要是记录refresh()方法中的finishBeanFactoryInitialization()方法。对于使用注解注入Bean的方式来说&#xff0c;这个方法是很重要的&#xff0c;它会初始化所…